Created
November 19, 2020 19:22
-
-
Save jubilatious1/e4da45c3020f3c8c745c2c4325e33c6f to your computer and use it in GitHub Desktop.
From https://stackoverflow.com/questions/64898346/raku-regex-how-to-use-capturing-group-inside-lookaheads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Raku (i.e. Perl6) "raku-regex-how-to-use-capturing-group-inside-lookaheads" | |
#examples with capture markers and 'doubled' capture markers: | |
say 'abc' ~~ / abc /; | |
#「abc」 | |
say 'abc' ~~ / a <( b )> c/; | |
#「b」 | |
say 'abc' ~~ / a <( (b) )> c/; | |
#「b」 | |
# 0 => 「b」 | |
say 'abc' ~~ / a <( b )> (c)/; | |
#「b」 | |
# 0 => 「c」 | |
say 'abc' ~~ / a <( (b) )> (c)/; | |
#「b」 | |
# 0 => 「b」 | |
# 1 => 「c」 | |
#examples pertaining to Julio's third regex code-block; | |
#note: different results from Julio with most-recent Rakudo-2020.10: | |
say 'abab' ~~ m:g/(a)<?before b>|b/; | |
#(「a」 | |
# 0 => 「a」 「b」 「a」 | |
# 0 => 「a」 「b」) | |
say 'abab' ~~ m:g/<((a))>b|b/; | |
#(「a」 | |
# 0 => 「a」 「a」 | |
# 0 => 「a」) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment