Re: eregi

From: Date: Thu, 02 May 2002 22:53:19 +0000
Subject: Re: eregi
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-95789@lists.php.net to get a copy of this message
In article <Pine.LNX.4.44.0205021718090.17412-100000@stoic.net>, mnc@stoic.net (Miguel Cruz) wrote: > On Thu, 2 May 2002, CC Zona wrote: > > mnc@stoic.net (Miguel Cruz) wrote: > >> preg_match("/{$start}(.*?)end/", $rf, my_var); > > > > Leave out the braces. > > Don't they get removed by the parser's handling of "double-quoted" strings > long before anything makes it to preg_match()? > > I almost always use the braces when inserting variables inside string > literals, just to avoid any chance of ambiguity. There's no ambiguity here since parentheses aren't legal in variable names, so the curly braces are just excess. Given the braces' significant as special regex characters, it can be a confusing distraction in this context, especially for newbies trying to grasp simply regex syntax. Better to save the braces for where they're needed to tell the parser or programmer how to interpret ambiguous code. -- CC

« previous php.general (#95789) next »