SPUG: SQL syntax Regular Expression
Colin Meyer
cmeyer at helvella.org
Sat Jun 22 11:34:39 CDT 2002
Hi Tim,
On Thu, Jun 20, 2002 at 09:15:05AM -0700, SPUG-list-owner wrote:
> On Thu, Jun 20, 2002 at 12:21:17AM +0000, Dan Sanderson wrote:
> >
> > This may or may not be worth mentioning in this particular case, but since
> > I learned this lesson the hard way, I feel like mentioning it every time I
> > see $` and $' (and $&) mentioned. From camel, 24.2.1:
> >
> > Avoid $& and its two buddies, $` and $'. Any occurrence in your program
> > causes all matches to save the searched string for possible future
> > reference. (However, once you've blown it, it doesn't hurt to have more
> > of them.)
>
> It's page 146 in the 3rd edition, which makes it clear that capturing
> parens have the same performance hit too, and you hardly see people
> becoming zealots in their avoidance!
The difference is that using $` or $' make *every* regex take the
performance hit. Using capturing parens only effect the regex[s] that
they appear in.
"... if you never use $`, $&, or $', then patterns without capturing
parentheses will not be penalized."
Have fun,
-C.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list