I need to know if there is a regular expression for testing for the presence of numbers in strings that:
- Matches
Lorem 20 Ipsum
- Matches
Lorem 2,5 Ipsum
- Matches
Lorem 20.5 Ipsum
- Does not match
Lorem 2% Ipsum
- Does not match
Lorem 20.5% Ipsum
- Does not match
Lorem 20,5% Ipsum
- Does not match
Lorem 2 percent Ipsum
- Does not match
Lorem 20.5 percent Ipsum
- Does not match
Lorem 20,5 percent Ipsum
- Matches
Lorem 20 Ipsum 2% dolor
- Matches
Lorem 2,5 Ipsum 20.5% dolor
- Matches
Lorem 20.5 Ipsum 20,5% dolor
That is, a regular expression that can tell me if in a string there is one or many numbers, but not as percentage value.
I've tried something as /[0-9\.,]+[^%]/
, but this not seems to work, I think because digits then not a percentage sign match also the 20
in the string 20%
. Additionally, I don't know how to tell not the entire percent
string in addition to the %
char.