Solved

Regular Express - FInding non-numeric data in strings

Posted on 2016-09-22
2
90 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

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…
I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…

623 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