Groups | Blog | Home
all groups > dotnet general > june 2005 >

dotnet general : Looking for a RegEx pattern


AWHK
6/28/2005 11:30:29 PM
I have some address string like this:

101st Street 45J
45th Karamba Street 123
1st Street 45L

I would like to use RegEx to extract any digits from the string as long as
they are not at the start of the string. I have a pattern like this
(?!^\d+)\d+ which works fine on '1st Street 45L' (captures 45 but not 1) as
it should. But in example '45th Karamba Street 123' it captures 5. What is
wrong?

I must say that I am not an expert on regular expressions...

Andreas :-)

v-kevy NO[at]SPAM online.microsoft.com
6/29/2005 12:00:00 AM
Hi Andreas,

Based on the regex you have provided, I noticed that we have to use
negative lookbehind instead of negative lookahead. You can try to use the
following pattern. It works fine on my machine.

(?<!^\d*)\d+

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
AddThis Social Bookmark Button