RE: [PHP] regexp appears to be faulty!?

From: Date: Tue, 24 Feb 2004 14:33:04 +0000
Subject: RE: [PHP] regexp appears to be faulty!?
Groups: php.general 
Request: Send a blank email to php-general+get-178699@lists.php.net to get a copy of this message
On 24 February 2004 12:40, Henry Grech-Cini wrote: > Hi All, > > function extractFieldsets($subject) > { > $regexp="/<fieldset([^>]*)>[^(<\/fieldset>)]*/i"; This: [^(<\/fieldset>)] will match any *single* character except the ones listed -- i.e. any character that isn't one of: ()<>/defilst So this: [^(<\/fieldset>)]* will match any run of characters that is not in that set. > > And it produced; > > (0)= > (0)=[<fieldset attribute="hello">con] > (1)=[<fieldset attribute="goodbye">goo] > > Why did it get three letters after the end of the "fieldset" tag???? By coincidence, the 4th letter in each case is one of the set listed above, and so ends the match: "t" in "content" and "d" in "goodbye". If the second example had ahppened to be, say, "au revoir", you'd have got 4 characters ("au r"). 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@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#178699) next »