jaynesh — 2011-12-08T06:00:51-05:00 — #1
lets say my form value is
&hello john &bye jacob &goodafternoon
How can I store all the values starting with & in a var?
paul_wilkins — 2011-12-08T06:09:11-05:00 — #2
You can use a regular expression that gets all of the characters that start with an ampersand.
var matches = field.value.match(/(&\\S+)/g);
jaynesh — 2011-12-08T06:16:48-05:00 — #3
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?
paul_wilkins — 2011-12-08T06:19:57-05:00 — #4
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.