regex after

Documentation for regex after assembled from the following types:

language documentation Regexes

From Regexes

(Regexes) regex after

To check that a pattern appears after another pattern, use a lookbehind assertion via the after assertion. This has the form:

<?after pattern>

Therefore, to search for the string bar immediately preceded by the string foo, use the following regexp:

rx{ <?after foo> bar }

For example:

say "foobar" ~~ rx{ <?after foo> bar };   # OUTPUT: «bar␤» 

However, if you want to search for a pattern which is not immediately preceded by some pattern, then you need to use a negative lookbehind assertion, this has the form:

<!after pattern>

Hence all occurrences of bar which do not have foo before them would be matched by

say "foobar" ~~ rx{ <!after foo> bar }    # OUTPUT: «Nil␤»