Capturing Text Inside HTML or XML Tags : ereg « String « PHP






Capturing Text Inside HTML or XML Tags

 
<?php 

$text = "<p>This is some text here \"</p>\".</p>"; 
ereg("<p>(([^<\"]|[^<]*<[^\/][^<])*(\"[^\"]*\"([^<\"]|[^<]*<[^\/][^<])*)*)?<\/p>", $text, $matches); 
echo "Found text: " . $matches[1] . "\n"; 
?>
  
  








Related examples in the same category

1.Displaying elements of $regs array
2.Filling Patterns with ereg
3.ereg() function searches a string, returning true if the pattern is found, and false otherwise.
4.ereg.php
5.break $url down into three distinct pieces