-1

I'm using below regular expression to match numbers that includes decimals, negative numbers inside quotes ("). What changes should I be doing so that it does not match "#1200"?

\"(-?\d*.?\d+)\"

"1200"     ---> matches as expected
"1200.67"  ---> matches as expected
"-1200"    ---> matches as expected
"-1200.67" ---> matches as expected
"#1200"    ---> I'm not expecting this to match. As you can see It has # at the beginning.
Jyoti Prasad Pal
  • 1,569
  • 3
  • 26
  • 41

1 Answers1

3

I believe it's the . in your regular expression. You haven't escaped it so it's being interpreted as "match any character". It should work if you escape it like so:

\"(-?\d*\.?\d+)\"
ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86