Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regexes doc doesn't mention $/ backreferences inside regex #1545

Closed
timo opened this issue Sep 9, 2017 · 5 comments
Closed

regexes doc doesn't mention $/ backreferences inside regex #1545

timo opened this issue Sep 9, 2017 · 5 comments
Labels
docs Documentation issue (primary issue type)

Comments

@timo
Copy link
Contributor

timo commented Sep 9, 2017

Not only is it important to know how exactly to refer back to already-matched things (though it's very simple in perl6), but it's very important to know that $/ only updates whenever a { } is encountered or when a regex { } or similar is finished

@timo timo added the docs Documentation issue (primary issue type) label Sep 9, 2017
@lefth
Copy link
Contributor

lefth commented Sep 9, 2017

In particular, the docs don't say that you can't refer to an already-matched thing that has just been matched unless you force the named matches to update with { }. But numbered matches do seem to work immediately.

@timo
Copy link
Contributor Author

timo commented Sep 9, 2017

not only numbered matches, but also named matches. probably only references to $/ that are part of pieces of code, like <subrule(Bool.pick ?? $0 !! "yo")>

@JJ
Copy link
Contributor

JJ commented Jul 5, 2019

Let me see if I can come up with an example for this, as well as a reasonable use case.

@JJ
Copy link
Contributor

JJ commented Jul 7, 2019

I don't think I really understand what you propose.

say "zipi zape" ~~ /(\w)\w» \s+ \w+({$/})/;

This matches, but returns an empty match in the second case. Same if you use $0. Adding an empty block behind the first match:

say "zipi zape" ~~ /(\w){}\w» \s+ \w+({$/})/;

Does not make any difference. This does not either

say "zipi zape" ~~ /(\w){ $/ = $0 }\w» \s+ \w+({$/})/;

So what are you exactly proposing here?

JJ added a commit to JJ/my-raku-examples that referenced this issue Jul 7, 2019
@JJ
Copy link
Contributor

JJ commented Jul 7, 2019

We need to fix #2887 before this one.

@JJ JJ closed this as completed in 17a102a Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type)
Projects
None yet
Development

No branches or pull requests

3 participants