Entry
How do I find two patterns in a line with arbitrary number of characters between ?
Dec 1st, 2003 12:52
Jakub Vrana, Thomas Svensson,
With curly braces. Be warned about PHP interpretation of {$var} inside
a string - it's evaluated as $var. So you must escape the brace or
don't put variable inside a string.
<?php
$distance = 9;
ereg("patt1.{" . $distance . "}patt2", "patt1_2_4_6_8_patt2"); // true
ereg("patt1.{" . $distance . "}patt2", "patt1_patt2"); // false
?>
.{10} means 10 arbitrary characters.