betocarranza
asked on
.NET Simple Regular Expression
I need a regular expression which will match the following patter
somerandomtext HKS 1234 possiblysomemorerandomtext
From the above string, I would like to get back "HKS 1234". The number 1234 could be any number. There might not always be a space between HKS and the number. Thanks!
somerandomtext HKS 1234 possiblysomemorerandomtext
From the above string, I would like to get back "HKS 1234". The number 1234 could be any number. There might not always be a space between HKS and the number. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got it -
Dim m As Match = Regex.Match(TestString, "(HKS\s*\d+)")
Thanks for your help :)
Dim m As Match = Regex.Match(TestString, "(HKS\s*\d+)")
Thanks for your help :)
ASKER
That works if the input is
blahblah HKS 1234 blahblah
but not if it is
blahblah HKS 1234
or
HKS 1234 blahblah rir
or
HKS 1234
Any ideas?
Thanks!