sically if there is a space after the capital A, I would to ignore the A and the space and capture everything else. But if there is no space after the A I want to include the A in the capture.
You can try this regex in PCRE using match reset \K
:
\bA(?: \K)?\S+
\K
resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match. So in this case if there is a space after A
then \K
resets matched information thus allowing us to capture whatever comes after it i.e. \S+
.
4
solved How would I write a regular expression that captures A23 but not A 23