Regular Express - FInding non-numeric data in strings

tmajor99
tmajor99 used Ask the Experts™
on
Should be simple.  Just need a Reg Expression that would find non-numeric data in a string.  

For example

Column A
129.00                 -> Valid.  Decimal is OK
ABC                      -> Invalid  
A23                      --> Invalid
34                         --> Valid
9/22                     --> Invalid because of Slash
12&3                   --> Invalid because of &
300-AB               --> Invalid because of DASH and Alpha Chars
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
Hi.,

pls try

[^\d\.]+
to find non num
or
[\d\.]+
to find num
Regards
Top Expert 2010
Commented:
Note that the above pattern string will allow an entry like "123.45.678".  If that is what you want, you are all set.  If not, try:

^\d+(\.\d+)?$

That allows you to have a decimal portion, or not.  It does not accept numbers with commas as a thousand separator, though.  Do you need that?

Note: the above pattern returns a match if the entire input is a "valid number", and returns no match if not. So basically you are checking to see whether there is a match.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial