Reputation: 231
The ruby regex expression (\d*[,]?\d*[.]\d+
) matches both 45.00 and 45.00%. How to tune this regex that it matches only 45.00 and 45.00%
Upvotes: 1
Views: 1263
Reputation: 44346
Just add a negative lookahead and make the decimal matching possessive:
\d*[,]?\d*[.]\d++(?!%)
Upvotes: 3
Reputation: 16728
I am not sure exactly what you are looking for either. You can try this, it will match both 45.00 and 45.00%
(\d*[,]?\d*\.\d+[%]?)
But the best way to test regex's is with Rubular
You can enter several lines of test data and then check that your regex matches what you expect
Upvotes: 0