Is there a way to do negative and positive lookbehind in VBA regex?
I want to not match if the string starts with "A", so I am currently doing ^A at the start of the pattern, then removing the first character of match(0). Obviously not the best method!
I am using the regExp object.
VBA offers positive and negative lookaheads but rather inconsistently not lookbehind.
The best example of using Regex with VBA that I have seen is this article by Patrick Matthews
[Updated example using
Execute
rather thanReplace
]While I am not completely clear on your usage you could use a function like this with
for all words not starting with a it returns everything from the second character on (using a submatch - the pattern inside
(
and)
is submatch 1 -How about putting the ^A in a non-captured group and using the SubMatches property of the Match object to get your matched value?