SPUG: minimal unmatching regex
Ingy dot Net
ingy at ingy.net
Sun Aug 23 12:44:11 PDT 2009
On Sun, Aug 23, 2009 at 12:13 PM, Ken Clarke <k_clarke at perlprogrammer.net>wrote:
> Late to the party but I love regexes.
> Patrick's /[^\w\W]/ made me think of /[\d\D]/ or /[\s\S]/ or any character
> class containing complementary subsets
> My own invention is /^^/ or /$$/ or any match which can only occur once
> occuring twice
Neither of these works for the intended purpose.
/^^/ always matches, which stands to reason, since after you match the
front, you're still at the front.
$$ is an interpolated scalar variable.
print "match" if $$ =~ /$$/; # prints "match"
Also, even though $$ is readonly, I could easily use Inline::C or some XS
code to allow me to do this:
$$ = ""; $anything =~ /$$/;
> Still, my vote goes to Ingy's /.^/ because not only does it use the least
> characters (at least I havn't seen any single character candidate), but it
> also uses the least ink :)
> 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