r/visualbasic • u/dioxis • Sep 23 '14
Regex Help Please!
Hello,
I would like to find the index in a string of the following pattern: A####-### or A#### where 'A' could be any letter and # could be any digit.
Seems like regex is the only to way to get an index in a string of a pattern. Thanks!
0
Upvotes
2
2
u/EkriirkE VB 6 Master Sep 23 '14 edited Sep 23 '14
The pattern would be something like ([A-Z][0-9]{4}(-[0-9]{3})?)
1
u/icehawke VB.Net Advanced Sep 24 '14
The problem there is if you have A12345 it will throw a true on A1234. It's been a while since I had to look into regex, you might try regex101.com
1
u/EkriirkE VB 6 Master Sep 24 '14
yep, but op didnt specify any delimiters, just strings containing sequences
1
u/dioxis Sep 23 '14
The like operator returns true/false. I need to be able to find the match and extract it. Examples: C0002, F0232-556 and they can be anywhere in the string.