hankknight
asked on
JavaScript/REGEX: remove all words that do not begin with xyz
Using Regular Expressions and JavaScript, how can I remove all words that do not begin with xyz?
var str = 'xyz1 xyz2 xyzzy hello world xyz555 xyzttt';
str = str.replace(???????????????????????????????????);
alert(str); // should be: hello world
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Let me know if you want the space for any invalid words removed too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.