I am trying to make a REGEXP_LIKE where it is true if there is anything that is not a number in a string how would I do that?
CodePudding user response:
You can use:
- The PERL-like character class
\D
or - A non-matching character list
[^0-9]
or - A non-matching POSIX character class
[^[:digit:]]
So either:
REGEXP_LIKE(value, '\D')
REGEXP_LIKE(value, '[^0-9]')
REGEXP_LIKE(value, '[^[:digit:]]')
CodePudding user response:
The regexp symbol for not is ^
and you can apply this over all numbers like so [^0-9]
. This pattern would be true if 1 character was non-numeric.
So to apply it in your regexp_like statement, you can just wrap it in wildcards because you only need to find one non-numeric character in the string:
regexp_like([field], '[^0-9]')