Re: Regular Expression Problems-nearly there!

From: Date: Tue, 19 Dec 2000 03:49:07 +0000
Subject: Re: Regular Expression Problems-nearly there!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30986@lists.php.net to get a copy of this message
Hey Scott: > $pat = "<span class=subnav>(.+)<\/span>"; This is too greedy ^^^^ It's grabbing _everything_ up to the last </span>. Try this instead. $pat = "<span class=subnav>([[:alnum:][:space:]]*)</span>"; This new atom uses a bracket expression to only find letters, numbers and spaces. Thus the "<" for first </span> won't be grabbed by the atom. If you're going to have punctuation or other characters in these spans, you'll need to add them to the bracket expression I provided. Enjoy, --Dan -- PHP scripts that make your job easier http://www.analysisandsolutions.com/code/ SQL Solution | Layout Solution | Form Solution T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.general (#30986) next »