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. ( |$)
.