473,511 Members | 14,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Common Regex.IsMatch expressions

Anyone have a link to a list of Regex.IsMatch expressions for commonly used
edits, like phone number, date, ssn, etc. An example below was copied from
a book source, but is returning false on "01/01/2005" in strDate. (Just
starting into regular expressions).

Return (Regex.IsMatch(strDate, "^(0[1-9]|1[0-2])[./-]" + _

' "(0[1-9]|1[0-9]|2[0-9]|3[0-1])" + _

' "[./-](\\d{2}|\\d{4})$"))

TIA

Dean Slindee
Nov 21 '05 #1
3 10238
Dean,

I know this as the standard given links in these newsgroups.

RegexLib
http://www.regexlib.com/Default.aspx

Expresso
http://www.ultrapico.com/Expresso.htm

I hope this helps a little bit?

Cor
Nov 21 '05 #2
There are too many slashes in the last part (\\d{2}|\\d{4})$)
It should be (\d{2}|\d{4})$
"Dean Slindee" <sl*****@charter.net> wrote in message
news:Xn*****************@fe05.lga...
Anyone have a link to a list of Regex.IsMatch expressions for commonly
used
edits, like phone number, date, ssn, etc. An example below was copied
from
a book source, but is returning false on "01/01/2005" in strDate. (Just
starting into regular expressions).

Return (Regex.IsMatch(strDate, "^(0[1-9]|1[0-2])[./-]" + _

' "(0[1-9]|1[0-9]|2[0-9]|3[0-1])" + _

' "[./-](\\d{2}|\\d{4})$"))

TIA

Dean Slindee

Nov 21 '05 #3
On 2005-04-20, Dean Slindee <sl*****@charter.net> wrote:
Anyone have a link to a list of Regex.IsMatch expressions for commonly used
edits, like phone number, date, ssn, etc. An example below was copied from
a book source, but is returning false on "01/01/2005" in strDate. (Just
starting into regular expressions).

Return (Regex.IsMatch(strDate, "^(0[1-9]|1[0-2])[./-]" + _

' "(0[1-9]|1[0-9]|2[0-9]|3[0-1])" + _

' "[./-](\\d{2}|\\d{4})$"))


As Cor mentioned, Expresso (http://www.ultrapico.com/Expresso.htm) is a
good source of regexes as well as a good app to test them in.

On the above examples, though, a common problem in copying from books
into VB.Net is that a lot of languages force one to escape the backslash
character, while VB.Net does not. In languages like C, you'd type "\\"
when you really want "\".

That's the problem above. Replace "\\d" with "\d" and the regex should
work fine.
Nov 21 '05 #4

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

Similar topics

3
2060
by: Jon Maz | last post by:
Hi All, Am getting frustrated trying to port the following (pretty simple) function to CSharp. The problem is that I'm lousy at Regular Expressions.... //from...
8
2965
by: Johnny | last post by:
I need to determine whether a text box contains a value that does not convert to a decimal. If the value does not convert to a decimal, I want to throw a MessageBox to have the user correct the...
9
4564
by: Tim Conner | last post by:
Is there a way to write a faster function ? public static bool IsNumber( char Value ) { if (Regex.IsMatch( Value.ToString(), @"^+$" )) { return true; } else return false; }
5
1588
by: Kijak | last post by:
Hi, Im just starting working with REGEX and got a few problems. Could you tell me how to test if two strings can be found in another. ei: String to test: "This is a great car you got" Look...
5
2256
by: Dennis | last post by:
Should not the following return False if s="255xxxxyyy"? It seems to return True. Regex.IsMatch(s, "") -- Dennis in Houston
3
1112
by: Peter Proost | last post by:
Hi group, can the following be done by using a regex, I want a textbox only to contain numbers or . / + - ^ , but I've never used a regex before so I don't know how to go about it. Could I for...
8
1810
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the...
3
2281
by: ommail | last post by:
Hi I wonder if regular expressions are in general sower than using classes like String and Char when used for validating/parsing text data? I've done some simple test (using IsMatch()) method...
8
7598
by: =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?= | last post by:
Hi, I need to validate a textbox to have exactly 4 characters that represent the number 0001 to 9999 (cannot be 0000). The regext I came up with rather long: ^(\d){3} | \d{2}\d | \d\d{2} |...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.