Regex question
| From: | Jon Haworth | Date: | Wed, 09 Jan 2002 13:54:59 +0000 |
| Subject: | Regex question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79907@lists.php.net to get a copy of this message | ||
Hi all,
I've got a regex that's working fine, apart from one little problem.
$tags = array ("script",
"<!--<!\[CDATA\[",
"\]\]>-->");
foreach ($tags as $currentTag)
if (preg_match ("/^<\/". $currentTag. "/", $content))
// do something
(checking to see if anything in the $tags array is at the start of the
string)
The problem is that it's not picking up "<!--<![CDATA[" and
"]]>-->". I've
escaped the [ and ] as I know they're reserved in regexes, but it seems
there's something else that needs escaping or otherwise tweaking, and all
manner of experimentation has proved fruitless :-(
Can anyone help me out?
Cheers
Jon
Witan Jardine
13 Southampton Place
London WC1A 2AL
Tel: 020 7404 4004
Please visit us on the Internet:
http://www.witanjardine.co.uk/
The information included in this e-mail is of a confidential nature and is
intended only for the addressee. If you are not the intended addressee, any
disclosure, copying or distribution by you is prohibited and may be
unlawful. Disclosure to any party other than the addressee, whether
inadvertent or otherwise is not intended to waive privilege of
confidentiality.