all groups > c# > january 2005 >
You're in the

c#

group:

[R U a genius?] .Net regular expressions (csharp)


Re: [R U a genius?] .Net regular expressions (csharp) C.E.O. Gargantua
1/20/2005 3:08:26 PM
c#:

How about?

[0-9]{8}_[0-9]{6}

[quoted text, click to view]


--
Texeme
http://texeme.com

incognito () Updated Almost Daily
Re: [R U a genius?] .Net regular expressions (csharp) Jon Shemitz
1/20/2005 4:34:08 PM
[quoted text, click to view]

Or just @"\d{8}_\d{6}"

--

[R U a genius?] .Net regular expressions (csharp) Daniel Dupont
1/20/2005 11:31:34 PM
Hi there,
I want to test a String. This string must be made of
- 8 numbers
- then a single underscore
- and then 6 numbers

Can anybody tell me what can be the right .Net pattern ?

String sample :
"20041224_235959" (latest christmas)
"20011109_140000" (9/11 crime - CET)
"19891009_180000" (Berlin wall of shame)
"00001224_235959" (That's a joke ! ;-)

Thanks,
--
Re: [R U a genius?] .Net regular expressions (csharp) Daniel Dupont
1/21/2005 12:02:23 AM
[quoted text, click to view]

Ok that was not a matter of beeing a genius ;-))

Regex r = new Regex(@"[\d]{8}_[\d]{6}");
if (r.IsMatch(textBox1.Text,0) ){
label1.Text="match";
}else{
label1.Text="NO match !";
}
regards,

--
AddThis Social Bookmark Button