RE: [PHP] regex problem

From: Date: Fri, 15 Aug 2003 13:03:29 +0000
Subject: RE: [PHP] regex problem
Groups: php.general 
Request: Send a blank email to php-general+get-159681@lists.php.net to get a copy of this message
On 15 August 2003 12:02, Merlin wrote: > Hi there, > > I have a regex problem. > > Basicly I do not want to match: > > /dir/test/contact.html > > But I do want to match: > /test/contact.html > > I tryed this one: > ^[!dir]/(.*)/contact(.*).html$ Well, that's not going to work because the construct [!dir] means "match any single character that is ! or d or i or r. Even if you use the correct negation character, to give [^dir], that's still not going to work as it means match any ONE character which is neither d nor i nor r. I *think* what you want here is what's called a lookahead assertion, but I've never tried to use one of those so I'm not even going to attempt a suggestion; however, they are documented in the PHP manual at http://www.php.net/pcre.pattern.syntax#regexp.reference.assertions, so a good peruse through that section may set you on the way. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#159681) next »