Regular Expresssion
-
Hi , I needed to verify that the last 4 digits in a number are 0000. The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}" but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000 I am unable to think of a regular expression to validate this string. any help will be greatly appreciated. Thanks
-
Hi , I needed to verify that the last 4 digits in a number are 0000. The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}" but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000 I am unable to think of a regular expression to validate this string. any help will be greatly appreciated. Thanks
fififlowertot wrote:
Hi ,
I needed to verify that the last 4 digits in a number are 0000.
The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}"
but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000
I am unable to think of a regular expression to validate this string. any help will be greatly appreciated.This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:
^(\d*(0){4})
[Edited to add deleted question in]
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Thursday, April 7, 2011 12:33 PM
-
fififlowertot wrote:
Hi ,
I needed to verify that the last 4 digits in a number are 0000.
The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}"
but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000
I am unable to think of a regular expression to validate this string. any help will be greatly appreciated.This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:
^(\d*(0){4})
[Edited to add deleted question in]
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Thursday, April 7, 2011 12:33 PM
yeah i was just deleting this when the mail of a reply came in inbox. thanx.
-
yeah i was just deleting this when the mail of a reply came in inbox. thanx.
You're welcome.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
yeah i was just deleting this when the mail of a reply came in inbox. thanx.
Don't delete your posts! 0) There is a Regular Expression forum. 1) Have you tried Expresso? 2) Have you tried <a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx">this</a>[<a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx" target="_blank" title="New Window">^</a>]? I don't know why you would want to be capturing the zeroes if you just want to do validation. Did you intend to escape the hyphen (-) rather than the left-parenthesis (() ?
-
fififlowertot wrote:
Hi ,
I needed to verify that the last 4 digits in a number are 0000.
The number was of format 999999-0000 so i checked with a regular expression @"\d-\(0){4}"
but now the '-' will not be there and it always just a number with last 4 digits as 0 i.e 0000
I am unable to think of a regular expression to validate this string. any help will be greatly appreciated.This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:
^(\d*(0){4})
[Edited to add deleted question in]
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Thursday, April 7, 2011 12:33 PM
Pete O'Hanlon wrote:
the regex for this is:
^(\d*(0){4})
Send this in to Alex Trebeck for use on Jeopardy, and we'll all guess what the question was. :laugh: "I'll take code fragments for a thousand, Alex."
There is water at the bottom of the ocean. My Mu[sic] My Films My Windows Programs, etc.
-
Don't delete your posts! 0) There is a Regular Expression forum. 1) Have you tried Expresso? 2) Have you tried <a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx">this</a>[<a href="http://www.codeproject.com/KB/string/RegexTester\_.aspx" target="_blank" title="New Window">^</a>]? I don't know why you would want to be capturing the zeroes if you just want to do validation. Did you intend to escape the hyphen (-) rather than the left-parenthesis (() ?
PIEBALDconsult wrote:
Don't delete your posts!
Unless of course you've come to realize that what you typed makes you look like a complete tool. There are exceptions to every rule. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997 -
PIEBALDconsult wrote:
Don't delete your posts!
Unless of course you've come to realize that what you typed makes you look like a complete tool. There are exceptions to every rule. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997Is this what's meant by a regular expression tool?
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
Is this what's meant by a regular expression tool?
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
The CCC?
-
The CCC?
Dalek Dave's a tool? You could well be right. ;)
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
PIEBALDconsult wrote:
Don't delete your posts!
Unless of course you've come to realize that what you typed makes you look like a complete tool. There are exceptions to every rule. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997No, not even then. And, no there are not.