Last post Jan 07, 2014 04:57 PM by kmcnet
Jan 07, 2014 03:17 PM|kmcnet|LINK
Hello everyone and thanks for your help in advance. I need to scan a string and retrieve matches for a pattern that will be like "MRNumber 1234567". The MR Number will always be present and the numeric portion could be anywhere between 1 and 999999. The numeric portion will always be numeric and will have no other characters in it. I have tried several permutations of
Dim Pattern As String = "[MR Number \&0-9]"
out success. Any help would be appreciated.
Jan 07, 2014 03:33 PM|Rion Williams|LINK
The following pattern should work for you :
or if you know that the string will only consist of your number, you can use '^' and '$' to target the beginning and end of your string :
It explicitly requires the string "MRNumber" followed by a single space and then any value from 0-999999. It should be noted that the example string that you provided of "MRNumber 1234567" should be invalid as per your requirements.
If you do need to explicitly not allow for "MRNumber 0" and only use 1-999999, change your expression to the following :
You can see an interactive example of this working below :
Jan 07, 2014 04:57 PM|kmcnet|LINK
Perfect!!. Thanks so much for the help.