Updated integer regexp to allow for negatives#40
Conversation
There was a problem hiding this comment.
Can you explain what the regular expression is doing? Why not just [-+]?\d+?
There was a problem hiding this comment.
No, I can't explain it : ) I'm not the best with these. I was going off of the SO link I found + the unit test. I linked it in the PR. There is an explation there.
There was a problem hiding this comment.
[+-]?
one of +, -, or nothing
(?<!\.)
Negative lookbehind, makes sure that a literal dot will not be matched at this position
\b
“the boundary between a word char (\w) and something that is not a word char”
[0-9]+
One or more digit
\b
-''-
(?!\.[0-9])
Negative lookahead, will make sure a literal dot followed by a digit is not matched
All in all, it means that it will match things like 42, +42, and -42, but not floats like 42.6 or .42
Found this while looking for TODOs
Implemented this pattern instead. Added a unit test and it seems to be working.