Regexp question:
Can one match if two words appear at the same time on a single line – but not if they
are more than say three words apart?
Example:
match and apart
should match in
“my attempts to match words apart are not successful”
and
“my attempts to match two words apart are not successful”
but not in
“my attempts to match three or more words apart are not successful”
Thanks.
This should work:
\sis a whitespace character and\Sis a non-whitespace character. For the single line aspect, you might want to change\sto[^\S\n\r]as\sdoes also contain the line break characters\nand\r.