Documentation for regex
&& assembled from the following types:
Matches successfully if all
&&-delimited segments match the same substring of the target string. The segments are evaluated left to right.
This can be useful for augmenting an existing regex. For example if you have a regex
quoted that matches a quoted string, then
/ <quoted> && <-[x]>* / matches a quoted string that does not contain the character
Note that you cannot easily obtain the same behavior with a lookahead, that is, a regex doesn't consume characters, because a lookahead doesn't stop looking when the quoted string stops matching.
say 'abc' ~~ / && . /; # OUTPUT: «Nil␤»say 'abc' ~~ / . && . /; # OUTPUT: «｢a｣␤»say 'abc' ~~ / . /; # OUTPUT: «｢a｣␤»say 'abc' ~~ / .. /; # OUTPUT: «｢ab｣␤»