I have this capturing subgroup in my regex statement. What I am trying to achieve is to add an exception to the bold/first matching group ([a-zA-Z]{2}) which should not match the specific word "PT". I am using VBScript.RegEx which is said to be similar to Javascript RegEx.
([a-zA-Z]{2}|[a-zA-Z]{1}\d{1}|\d{1}[a-zA-Z]{1})
Refer to the table below for the decision tree.
| word | match |
|---|---|
| AA | Pass |
| A1 | Pass |
| 1A | Pass |
| PT | Fail |
| pt | Fail |
| pT | Fail |
>Solution :
You can use a negative lookahead conditional:
(?![Pp][Tt])\w{2}
The (?! means the next two characters should not match the value inside the parenthesis, in this case [Pp][Tt].