There are two types of alternation in Raku's regex: the | and ||. What is the difference ?
say 'foobar' ~~ / foo || foobar / # 「foo」
say 'foobar' ~~ / foo | foobar / # 「foobar」
There are two types of alternation in Raku's regex: the | and ||. What is the difference ?
say 'foobar' ~~ / foo || foobar / # 「foo」
say 'foobar' ~~ / foo | foobar / # 「foobar」
Copyright © 2021 Jogjafile Inc.
The || is the old alternation behaviour: try alternation from the first declared to the last
The | try alternation from the longest to the shortest declarative atom. It is called the Longest Token Matching Spec strategy.
More detailed answer in this post