Skip to content

Instantly share code, notes, and snippets.

@littlebenlittle
Last active November 22, 2020 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littlebenlittle/92e3fbfaf9cd5b81a3b9fb5af8e9df5f to your computer and use it in GitHub Desktop.
Save littlebenlittle/92e3fbfaf9cd5b81a3b9fb5af8e9df5f to your computer and use it in GitHub Desktop.
#|(
Match against an infinite family of <!before> patterns
)
say 'x_x___x________' ~~ /
[
| 'x'
| '_' <!before [
| $
| '_' <?before $>
| '_' <?before ['_' <?before $>]>
| '_' <?before ['_' <?before ['_' <?before $>]>]>
# ...
]>
]+
/;
@littlebenlittle
Copy link
Author

Is there a way to construct the rest of the pattern implied by the ...?

@littlebenlittle
Copy link
Author

littlebenlittle commented Nov 22, 2020

A possible solution:

say 'x_xxxx_____x__xx______' ~~ / ['x'+]+ % '_'+ /;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment