What is the best way to select all the text between 2 tags - ex: the text between all the 'pre' tags on the page.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
You can use
"<pre>(.*?)</pre>"
, (replacing pre with whatever text you want) and extract the first group (for more specific instructions specify a language) but this assumes the simplistic notion that you have very simple and valid HTML.As other commenters have suggested, if you're doing something complex, use a HTML parser.
To exclude the delimiting tags:
This seems to be the simplest regular expression of all that I found
(?:<TAG>)
from the matches([\s\S]*)
in the matches(?:<\/TAG>)
from the matchesTry this....
I use this solution: