Solved

Regular Express - FInding non-numeric data in strings

Posted on 2016-09-22
2
56 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 49

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…

776 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