Forum Moderators: coopster
preg_match("{<\/head>(.*)powered}i", $webpage_contents, $matches2);
I'd like to retreive everything between:
</head> ...... powered
Unfortunately, I've not been able to find a delimiter that won't be contained in the " ...... " part. Now, I'd like to be able to run this preg_match so that all delimiters in the ..... part of the expression get escaped. Are you saying that I should just go ahead and escape all characters in the string before doing the match?
The first sign of the pattern string is considered the pattern delimiter. In this case it is the single quote. Not using the slash when matching html tags has the advantage that you do not have to escape the slash in your pattern.
Notice emphasis on pattern. There is no need to escape the RE delimiter in the string. All you need to make sure is that it is not used or escaped in your pattern.
$string = 'Aaron rules!';
preg_match("!^(\w+)!", $string, $m);
will work just fine and match Aaron. If you wanted to match rules! you would either use a different delimiter thatīs not contained in your pattern or escape the exclamation mark.
preg_match("{(\w+!)}", $string, $m);
preg_match("!(\w+\!)!", $string, $m);
I hope that sheds some light on my last statement.
Andreas