Re: Lookbehind assertion weirdness

2019-08-22 Thread Brad Gilbert
A lookbehind assertion, lookahead assertion, and well every other assertion are zero width. That means they do not advance the cursor. So in the case of `` it asserts that the previous two characters are `1:` If that is a true assertion, then nothing happens. If it is instead false, it causes the

Re: Lookbehind assertion weirdness

2019-08-22 Thread William Michels via perl6-users
Hi Sean, From the docs: Lookbehind assertions: https://docs.perl6.org/language/regexes#Lookbehind_assertions "To check that a pattern appears after another pattern, use a lookbehind assertion via the after assertion. This has the form: "Therefore, to search for the string bar immediately pr

Re: Lookbehind assertion weirdness

2019-08-22 Thread yary
Perl 6 is doing the right thing. The dot matches any character. In this case, matching the final ':'. The next bit of the regex says the cursor has to be after 1:, and indeed, after matching the ':' the cursor is after '1:', so the substitution succeeds. Maybe you want s//x/ to append 'x' after '1

Lookbehind assertion weirdness

2019-08-22 Thread Sean McAfee
This seems like a bug, but I thought I'd ask here before reporting it. $_ = '1:'; s/./x/; .say; This prints "1x". Is that what's supposed to happen somehow? I would have thought that '1:' should only match a literal "1:", leaving nothing for the dot to match.