Search for tags with the id attribute in html. The specific point is the html tag with the id = "" in the angle brackets. For example:
String <div style = "float: left" id = "AB"> 123213 </div> <div class = "a123"> 21314423 </div>
Does not match <div class = "a123"> ...... </Div> Content
This example can be used.
| The code is as follows: |
Copy code |
<[A-zA-Z0-9] [^>] +? Id = [^>] +?>. *? </Div> |
Match
The previous php example:
| The code is as follows: |
Copy code |
<? 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> '; Print_r ($ r ); Echo '</pre> '; ?>
|
Output in this example
| The code is as follows: |
Copy code |
Array ( [0] => Array ( [0] => <div style = "float: left" id = "AB"> 123213 </div> ) ) End .. |