Skip to content

Commit

Permalink
just use a relative backreference
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 26, 2015
1 parent ca160cc commit 648eaa1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -8,15 +8,13 @@ has tree => sub { ['root'] };
has 'xml';

my $ATTR_RE = qr/
([^<>=\s\/]+|\/) # Key
([^<>=\s\/]+|\/) # Key
(?:
\s*=\s*
(?:
"([^"]*?)" # Quotation marks
([\"'])(.*?)\g{-2} # Quoted
|
'([^']*?)' # Apostrophes
|
([^>\s]*) # Unquoted
([^>\s]*) # Unquoted
)
)?
\s*
Expand Down Expand Up @@ -126,7 +124,7 @@ sub parse {
# Attributes
my (%attrs, $closing);
while ($attr =~ /$ATTR_RE/go) {
my ($key, $value) = ($xml ? $1 : lc $1, $2 // $3 // $4);
my ($key, $value) = ($xml ? $1 : lc $1, $3 // $4);

# Empty tag
++$closing and next if $key eq '/';
Expand Down

0 comments on commit 648eaa1

Please sign in to comment.