SPUG: When is a caret just a caret? And what about dollar?
derykus at gmail.com
Sat Aug 22 05:26:38 PDT 2009
No, caret needs backwhacking to be a self-match:
perl -wle "use re 'debug'; /^^/"
Compiling REx "^^"
1: BOL (2)
2: BOL (3)
perl -wle "use re 'debug'; /^\^/"
Compiling REx "^\^"
1: BOL (2)
2: EXACT <^> (4)
On Fri, Aug 21, 2009 at 11:47 PM, Michael R. Wolf <MichaelRWolf at att.net>wrote:
> I seem to remember that the meaning of caret in a regex is
> context-sensitive, and it can be an anchor, a complement, or just (with
> apologies to Sigmond) a caret.
> My memory is that . Ergo, /^^[^^]^/ would match "beginning of line then
> caret then anything-but-a-caret then caret". I can't seem to find support
> for this (long-held) belief. Have I been wrong for this long?
> And while I'm at it, how 'bout dollar? I thought it was an anchor iff it
> was the last character in the regex, else it introduced a scalar variable
> for interpolation.
> It seems that the documentation says that caret and dollar are *always*
> metacharacters. Any ideas how I could have been mislead by a (seemingly)
> similar set of rules that I may have misinterpreted? Has their meaning
> changed in previous versions of Perl (or the Perl regex engine)?
> Michael R. Wolf
> All mammals learn by playing!
> MichaelRWolf at att.net
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays
> WEB PAGE: http://seattleperl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the spug-list