Skip to content Skip to sidebar Skip to footer

Javascript Error Regex Not A Function?

I found some code online (stackoverflow https://stackoverflow.com/a/5774234/150062) that does exactly what I need. But I can't seem to get it running. I get an error ''/(\\d+)\\s*(

Solution 1:

This used to be possible, you can replace the call with exec for exact same mechanism:

m = regex.exec(s)

See http://whereswalden.com/2011/03/06/javascript-change-in-firefox-5-not-4-and-in-other-browsers-regular-expressions-cant-be-called-like-functions/


Solution 2:

i think

regex.match(value)//or regx.exec(value)

is function you are looking for

regex is a RegExp object, not a function. here listing of method and function of Regular Expressions methods and usage

if match is not working than tryout .test() method like this

var match = /sample/.test("Sample text")

or

var match = /s(amp)le/i.exec("Sample text")

Post a Comment for "Javascript Error Regex Not A Function?"