Last active
August 29, 2015 14:06
-
-
Save gray/f16ece0398d24724f5ed to your computer and use it in GitHub Desktop.
regex: match nested HTML tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will capture the contents of the div of interest, including any nested div tags. | |
use 5.010; | |
my ($div) = $content =~ m[ | |
\Q<div id="matchme">\E | |
( (?> [^<]++ | <(?!/?div\b) | <div\b[^>]*+>(?1)</div> )*+ ) | |
</div> | |
]x; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment