Hi there,
I'm so frustrated! I am trying to get what I think should be a simple regular expression working, but it's evading me. In perl it would be
in javascript from what I have read match() or test() would be appropriate methods. All I need to do is check for the existance of a comma in a string so I can deal with the string as an array.
this returns myString.match() is not a function
I know that it's probably something really simple so apologies. I have searched and searched to find an answer but to no avail, I'm only testing in Firefox at present.
thanks
A
I'm so frustrated! I am trying to get what I think should be a simple regular expression working, but it's evading me. In perl it would be
Code:
my $myString = "blah,blah,blah";
if ($myString ~= m/\,/) {deal with as an array}
in javascript from what I have read match() or test() would be appropriate methods. All I need to do is check for the existance of a comma in a string so I can deal with the string as an array.
Code:
var myString = "blah,blah,blah";
var re = new RegExp(/,/); // commas are not treated as specials apparantly so no escaping is needed
if (myString.match(re)) {alert("this is an array!");}
this returns myString.match() is not a function
I know that it's probably something really simple so apologies. I have searched and searched to find an answer but to no avail, I'm only testing in Firefox at present.
thanks
A