473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

simple regex?

I know this is too easy, but I am not getting it. I want to regex string to
find any string that has non numeric characters, integers and floats
verification basically.

I am using the following:


!Regex.IsMatch( varValue, @"(\b[^A-Za-z\\.]*\b)" )

To filter through a basic list of data and results:

Data Results

=================================

"3174.00" pass

"435015" pass

"15" pass

" SQ. TUBING .065" fails

"20" pass

"248" pass

"1/2" fails

"0.00" pass

"G" fails

"01/31/06" fails

"ST-1020" fails

"Foot" fails

"16.533" pass

Thanks,

Jerry
Feb 21 '07 #1
1 1374
Hello Jerry,

I suggest you use positive verification, if at all possible - it's usually
much easier to define and clearer in its purpose than negative
verification. This is an integer:

\d+

And this is a float:

\d+\.\d+

(Note that the decimal separator depends on the locale that was used to
output the data.)

You can combine these two expressions:

\d+|\d+\.\d+

Or you can make part of it optional:

\d+(\.\d+)?

So it would be really easy to match exactly those of your entries that are
valid by your definition - everything else is, by definition, not valid.
Oliver Sturm
--
http://www.sturmnet.org/blog
Feb 21 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Howard Dean | last post by:
I have a string with several carriage returns in it. For example: "This is my test string" I wish to convert it to "This is my test string" (remove all carriage returns. Can someone tell me...
0
by: Daniel Perron | last post by:
Hi, I was trying to use Galois.Net to specify code generators and I had to look for some text template tool to simplify the syntax. I was looking for something similar to the syntax of an...
2
by: live your lives | last post by:
i am trying to validate a simple username textbox using RegularExpressionValidator: TextBox tbUserName = new TextBox(); tbUserName.ID = "tbUserName"; string strPatternUserName = @"\W"; //...
7
by: Razzie | last post by:
Hey all, Decided to give a shot at Regular expressions - need a bit of help :) I can't seem to find the right regex for matching words like "*test*" or *somevalue*" - in short, all words...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
0
by: Tom Shelton | last post by:
This is a simple example of a numeric only text box. It allows only the entry of integer values. The advantage of this example is that it also handles user attempts to past non integer text data...
2
by: Thomas T. Veldhouse | last post by:
Hello. I have been working with a client of mine on their seriazation code and we seem to have run into an issue when we migrated from .NET 1.1 to .NET 2.0. We have a framework of business...
5
by: FBergemann | last post by:
I use SunOS 5.8, gcc 3.3.2, boost 1.33.1. I have build the entire boost package and try to compile a simple example: #include <iostream> #include <string> #include <boost/regex.hpp //...
1
by: Alan Patterson | last post by:
I have installed boost 1.33.1 and everything compiled and installed fine on Windows using Visual C++ 8.0. I wrote the following simple code to test the regex library and it doesn't seem to work....
4
by: bg_ie | last post by:
I have the following Regex - oldString = @"C:\ta"; Regex regexEndsInBackslash = new Regex(oldString + @"\\", RegexOptions.Singleline | RegexOptions.IgnoreCase); Any ideas why none of the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.