Solved

Regular Express - FInding non-numeric data in strings

Posted on 2016-09-22
2
63 Views
Last Modified: 2016-09-27
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
0
Comment
Question by:tmajor99
2 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41810692
Hi.,

pls try

[^\d\.]+
to find non num
or
[\d\.]+
to find num
Regards
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 41811081
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.
1

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question