regex - Regular Expression matching floating point numbers not ending with -
I am trying to extract CSS status from the string - example:
"top Right center on the left 0 0% 50% 100% 360 degree 15.5% -16.3% "The problem is that the string includes an angle" 360deg ". I do not want any number to be matched with regular expressions after "deg" Currently, I have: (- ([[0-9] *. [0-9] + | [0- 9] +)). (Center) | (Top) | (Left). (Below). (Right)
It matches all the numbers (Inc. angle - which I do not want). I have tried to use a negative lookhead:
(- [[0-9] *. [0-9] + | [0- 9] +)) ( ?! Degree) (center) | (Top) | (Below). (Below). (Right)
but it only appears to remove the end zero from 360deg - that is 360deg => 36
Does anyone know that Negative attitudes to removing angles are not successful? Regular expression match because it did not get two digits after "deg": 36
followed by 0
and it is not "deg". [0-9] *
is generally greedy but if this match fails, it will try to match the fewer digit options. You can put a negative look at this:
(?! Deg | [0-9.])
Comments
Post a Comment