Hello
lets say my form value is
&hello john &bye jacob &goodafternoon
How can I store all the values starting with & in a var?
Regards
| SitePoint Sponsor |


Hello
lets say my form value is
&hello john &bye jacob &goodafternoon
How can I store all the values starting with & in a var?
Regards


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript


Hi thank you for your response.
Yes but how do I store that in a var.
for example If the form value is &hello jacob
How do I store &hello in a var?
Regards


The example that I gave stores the values in a var called matches as an array, such as:
['&hello', '&bye', '&goodafternoon']
If you don't want the ampersand included in the string, you can match /&(\S+)/g instead of /(&\S+)/g
You can use the standard array-index notation to retrieve one of the string values from that array.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Bookmarks