[buug] regex question

Nick Moffitt nick at zork.net
Wed Apr 30 13:56:24 PDT 2003


begin  Aaron T Porter  quotation:
> On Wed, Apr 30, 2003 at 01:40:52PM -0700, johnd wrote:
> > I need a regex to substitue on that gives me
> > the part after the = and before the &
> 
> 	Something like:
> 
> 	($id) = $_ =~ m"UserID=(.*)&";

	That's nice, but it does a lot of backtracking from the end to
figure out which & is the terminating symbol.  It's much more
efficient to use some variant of "[^&]+" instead of ".*".  The match
then stops at the first & it sees instead of hoping for a later one in
the string.

-- 

end



More information about the buug mailing list