Skip to content Skip to sidebar Skip to footer

Regex String Show Me An Error

What is wrong with my regex It is my first try to use regex. However I have a small problem. When I run my regex in chrome console, it seems to work. However my Komodo Edit shows m

Solution 1:

- is used to select range of characters.

Move - to the end of regex.

/([^0-9,\s-])/

OR escape it using slash \

/([^0-9,\-\s])/

Solution 2:

s = s.replace(/([^0-9,\s-])/g,"");

Keep - at end or escape it.- inside character class forms a range(invalid in this case).

Post a Comment for "Regex String Show Me An Error"