Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 09, 2012 05:15 PM by young345
Member
204 Points
730 Posts
Jul 09, 2012 12:30 AM|LINK
Hi,
I have a regular expression var regex which is returned as "^([1-9]\d{8})$"
When I use value.match(regex); ... value.match is always returning null.
I read somewhere the the regex shouldnt be a string and I should replace the " with /
However, I don't know how I can do this as regex.replace(""", "/") doesn't seem to work.
How can I use this replace method?
Please any help and examples on this would be very much appreciated.
Thank you
All-Star
15346 Points
3142 Posts
Jul 09, 2012 05:08 PM|LINK
if there is no match then it does return null for replace you should again
Jul 09, 2012 05:15 PM|LINK
the problem was i needed to do /^([1-9]\d{8})$/ instead of "^([1-9]\d{8})$"
young345
Member
204 Points
730 Posts
why does .match for regular expression always returns null
Jul 09, 2012 12:30 AM|LINK
Hi,
I have a regular expression var regex which is returned as "^([1-9]\d{8})$"
When I use value.match(regex); ... value.match is always returning null.
I read somewhere the the regex shouldnt be a string and I should replace the " with /
However, I don't know how I can do this as regex.replace(""", "/") doesn't seem to work.
How can I use this replace method?
Please any help and examples on this would be very much appreciated.
Thank you
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: why does .match for regular expression always returns null
Jul 09, 2012 05:08 PM|LINK
if there is no match then it does return null for replace you should again
young345
Member
204 Points
730 Posts
Re: why does .match for regular expression always returns null
Jul 09, 2012 05:15 PM|LINK
the problem was i needed to do /^([1-9]\d{8})$/ instead of "^([1-9]\d{8})$"