Home >Web Front-end >HTML Tutorial >Use regular expression to find html tags with id attribute in html
For example:
String8e62618ac3ec95641599edb0d182503812321316b28748ea4df4d9c2150843fecfba68c53114d76b92ed7373f1c8f5d2221d192131442316b28748ea4df4d9c2150843fecfba68
Does not match the content of c53114d76b92ed7373f1c8f5d2221d19...16b28748ea4df4d9c2150843fecfba68
To write this example, you can use
bf25faba508d5088b42ea98f8e3d0399 ]+?id=[^>]+?>.*?16b28748ea4df4d9c2150843fecfba68
Match
Previous php example:
<?php $str = '<div style="float:left" id="ab">123213</div><div class="a123">213123</div>'; $search = '#<[a-zA-Z0-9][^>]+?id=[^>]+?>.*?</div>#is'; preg_match_all($search,$str,$r); echo '<pre class="brush:php;toolbar:false">'; print_r($r); echo ''; ?>
This example output
Array ( [0] => Array ( [0] => <div style="float:left" id="ab">123213</div> ) )
For more articles related to using regular expressions to find html tags with id attributes in html, please pay attention to the PHP Chinese website!