By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,799 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,799 IT Pros & Developers. It's quick & easy.

Regular expressions.....

P: n/a
I am writing some validations code to make sure that date string data has
only two "/" characters in a string. Order of appearance of "/" is
irrespective.

How to write a regular expressions code to validate that a given string has
only two "/" in a given string. .Net 1.1.

Thanks,

Smith


Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Hi Peter ! :O)

Do you really need a regular expression ?
There many ways to perform this test... here's three of them including a
Regex solution.. :
'***
Dim s As String = "my / test / string"
Console.WriteLine(s.Split("/").Length - 1 = 2)
Console.WriteLine(s.Length - s.Replace("/", "").Length = 2)
Console.WriteLine(Regex.IsMatch(s, "^([^/]*)/{1}([^/]*)/{1}([^/]*)$"))
'***

--
Best Regards
Yanick
"Peter Smith" <Pe*********@hotmail.com> a écrit dans le message de
news:uI**************@TK2MSFTNGP14.phx.gbl...
I am writing some validations code to make sure that date string data has
only two "/" characters in a string. Order of appearance of "/" is
irrespective.

How to write a regular expressions code to validate that a given string has only two "/" in a given string. .Net 1.1.

Thanks,

Smith

Nov 21 '05 #2

P: n/a
In article <uI**************@TK2MSFTNGP14.phx.gbl>, Peter Smith wrote:
I am writing some validations code to make sure that date string data has
only two "/" characters in a string. Order of appearance of "/" is
irrespective.

How to write a regular expressions code to validate that a given string has
only two "/" in a given string. .Net 1.1.

Thanks,

Smith


You could just use DateTime.ParseExact with your needed format.

--
Tom Shelton [MVP]
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.