Skip to content

Instantly share code, notes, and snippets.

@fghber
Last active April 24, 2018 20:09
Show Gist options
  • Save fghber/b658463011d8510a2a20a808a27495ba to your computer and use it in GitHub Desktop.
Save fghber/b658463011d8510a2a20a808a27495ba to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use YAPE::Regex::Explain;
my $regex = qr/\G([\w-]+).+?\b/;
my $xplain = YAPE::Regex::Explain->new($regex);
print $xplain->explain;
The regular expression:
(?-imsx:\G([\w-]+).+?\b)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
\G where the last m//g left off
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
[\w-]+ any character of: word characters (a-z,
A-Z, 0-9, _), '-' (1 or more times
(matching the most amount possible))
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
.+? any character except \n (1 or more times
(matching the least amount possible))
----------------------------------------------------------------------
\b the boundary between a word char (\w) and
something that is not a word char
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment