Skip to content

Instantly share code, notes, and snippets.

@sjaveed
Last active September 9, 2020 03:31
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 sjaveed/061c743b70376bb4b317ec46bcc5c000 to your computer and use it in GitHub Desktop.
Save sjaveed/061c743b70376bb4b317ec46bcc5c000 to your computer and use it in GitHub Desktop.
regex issues
use MONKEY-SEE-NO-EVAL;
my $regex-str = '"/greeting/" $<name> = (.+)';
my $path = "/greeting/bob";
say "Regex from String (Works)";
my $regex-from-str;
my $expr-to-eval = "\$regex-from-str = rx\{$regex-str\}";
EVAL $expr-to-eval;
say $path ~~ $regex-from-str;
say "Regex String (Doesn't Work - Why?)";
say $path ~~ /<$regex-str>/;
say "\nActual Regex (Works)";
say $path ~~ /"/greeting/" $<name> = (.+)/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment