<html> FIND ME <head> FIND ME </head> FIND ME <body> FIND ME <a href="FIND ME.HTML">FIND ME</a> FIND ME <a href="FIND ME.HTML">FIND ME</a> FIND MENOT </body> FIND ME </html>
Execution Time(sec.): 0.000039 Raw Match Pattern: (?si)\bFIND ME\b(?![^<>]*</a>)(?=([^<>]*<[^>]+>[^<>]*)+$|[^<>]*$)(?=(?:(?!<body).)*</body>) PHP Code Example: <?php $sourcestring="your source string"; preg_match_all('~(?si)\bFIND ME\b(?![^<>]*</a>)(?=([^<>]*<[^>]+>[^<>]*)+$|[^<>]*$)(?=(?:(?!<body).)*</body>)~',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?> $matches Array: ( [0] => Array ( [0] => FIND ME [1] => FIND ME ) [1] => Array ( [0] => </html> [1] => </html> ) )
<?php $sourcestring="your source string"; preg_match_all('~(?si)\bFIND ME\b(?![^<>]*</a>)(?=([^<>]*<[^>]+>[^<>]*)+$|[^<>]*$)(?=(?:(?!<body).)*</body>)~',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?>