Last active
October 17, 2018 19:52
-
-
Save voku/48eabc060e9caefd58f15e13b5ef48d3 to your computer and use it in GitHub Desktop.
regex - remove first html tag
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
<?php | |
$input_lines = ' <div>da<a> | |
lalll | |
</a>sda | |
</div>'; | |
$output = preg_replace('/^<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\1)>$/usi', '$3', trim($input_lines)); | |
echo $output; | |
/* | |
da<a> | |
lalll | |
</a>sda | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment