how can i get the text between search words like:
<html> TEXT </html> : in this case, i want to get the content "text"
Quick quesiton
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
preg_match('!<text>(.*?)</text>!im', $source, $matches);
echo '<pre>';
print_r($matches);Moved to Regex.
Re: Quick quesiton
truepal20032001 wrote:how can i get the text between search words like:
<html> TEXT </html> : in this case, i want to get the content "text"
Looks like he said he wanted to match just the text in between not the both the text in between and the markers it sits in between:!<text>(.*?)</text>!im
So:
Code: Select all
~(?<=<html>).*?(?=</html>)~Code: Select all
~(?<=<html>)(?:(?=<html>).)*(?=</html>)~s