How to explicitly define regex
(a numbered or named capture group) that always matches exactly zero characters?
> "abc" ~~ m/()abc/
===SORRY!=== Error while compiling:
Null regex not allowed
> my regex null {}
===SORRY!=== Error while compiling:
Null regex not allowed
> my regex null {<[]>}
regex null {<[]>}
> "abc" ~~ m/<null>abc/
False
Of course, I can use something like the following, but I'm looking for an idiomatic way to do this.
> my regex null {a ** 0}
regex null {a ** 0}
> "abc" ~~ m/<null>abc/
「abc」
null => 「」
UPD: It works, but the best way?
> my regex null { '' }
regex null { '' }
> "abc" ~~ m/<null>abc/
「abc」
null => 「」
> "abc" ~~ m/('') abc/
「abc」
0 => 「」
source
share