javascript - Regex not validating end of string -


consider following scenario (javascript code):

regex = new regexp((/([\d,.]+)[ $]/)); value = "2.879"   

the regexp doesn't match value, matches (value+" ") therefore think $ not matched? why that?

shouldn't $ validate end of string?

special characters $ don't have same meaning inside character class. in character class they're characters, [ $] match either space character or $ character. won't match end of string.

if want match either space character or end of string, should use alternation, i.e. ( |$).


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -