Reputation: 743
I am looking to match using regexp in VBScript strings that begin with one or more digits have intervening Capital letters or spaces OR strings that begin with Capital letters and spaces and end with one or more digits.
Tried "^([0-9]+[A-Z\s]+)|([A-Z\s]+[0-9]+)$"
but not working.
Example Match strings:
75 MANOJ TIGADI
VASANT KANETKAR 111
Upvotes: 2
Views: 80
Reputation: 163217
You could match it both ways using the alternation inside the grouping.
If you don't need the value as a group, you can make it non capturing.
If you don't want to match only spaces, but a single space between the uppercase chars and no trailing spaces, you can use an optional repeating group (?: [A-Z]+)*
Note that \s
could also possibly match a newline.
^(?:[0-9]+(?: [A-Z]+)*|[A-Z]+(?: [A-Z]+)* [0-9]+)$
Upvotes: 3