Instantly share code, notes, and snippets.

Embed
What would you like to do?
regex - remove first html tag
<?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