remove spaces and + symbols

I have a string from php parameter which I need the get rid of all the spaces and + symbols  

for example I need the 2 words from this stored in separate variables

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
var s = "Fred++++nurk+";
var t = s.replace(/(+)+/g,"+");
var terms = t.split("+");

terms[0] is "Fred"
terms[1] is "nurk"
RobOwner (Aidellio)Commented:

slight edit on the replace:

RobOwner (Aidellio)Commented:
so essentially what I've done is replace duplicate "+" with a single "+" and then split the string bases on that delimiter
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Dan CraciunIT ConsultantCommented:
@Rob: you're sure that's php? Cause variables in php should start with $...
RobOwner (Aidellio)Commented:
nope not sure at all! it's JavaScript! *smacks head* thanks Dan. I have a saved search that I'd supposed to give me JavaScript questions...
RobOwner (Aidellio)Commented:
With PHP the theory still applies:

$subject = "fred++++nurk+";
$pattern = '/[\+]+/';
$replacement = "+";
$t = preg_replace($pattern, $replacement, $subject);

$terms = preg_split("/\+/", $t);



Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dan CraciunIT ConsultantCommented:
Yup. But you forgot the spaces part:
>>get rid of all the spaces and + symbols

$pattern = '/[ +]+/';

Open in new window

RobOwner (Aidellio)Commented:
THanks Dan :)
Ray PaseurCommented:
If this is a query string (perhaps part of the URL) you might want to look at it with PHP var_dump() to see what is still there after the PHP script receives it.  Just a thought...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.