Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (20 sloc) 0.825 kB
use v6;
use Test;
#L<S05/Modifiers/"The new :r or :ratchet modifier">
# for other tests see
# t/spec/S05-mass/rx.t
# backtracking
regex aplus { a+ };
ok 'aaaa' ~~ m/ ^ <aplus> a $ /, 'normal regexes backtrack into subrules';
ok 'aaaa' !~~ m/ :ratchet ^ <aplus> a $ /, ' ... but not with :ratchet';
# what follows now might make your head twitch. Don't worry about that, it's
# normal. See for a
# discussion
ok 'aaaa' !~~ m/ :ratchet ^ [ :!ratchet <aplus> ] a /,
'if the failing atom is outside the :!ratchet group: no backtracking';
ok 'aaaa' ~~ m/ :ratchet ^ [ :!ratchet <aplus> a ] /,
'if the failing atom is inside the :!ratchet group: backtracking';
ok 'aaaa' ~~ m/ ^ :!ratchet <aplus> :ratchet a /,
'Same if not grouped';
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.