perl.golf...Re: regexp quickie by Phil Carmody- June 28, 2007 --- Shlomi Fish <shlomifiglu.org.il> wrote:> On Thursday 28 June 2007, Phil Carmody wrote:> > You guys amaze me! (And gals, too, in case Abigail reads this list. > > Sorry to disappoint you but Abigail is a guy (at least in the context of > Perl):...> http:www.flickr.comphotoscogurov42641335inphotostreamOh, that&39;s going to get confusing... I&39;ll have no idea what personal pronoun touse when referring to hän in the future on littlegolem, usenet, and here....http://www.nntp.perl.org/group/perl.golf/2007/06/msg2477.html Re: regexp quickie by Shlomi Fish- June 28, 2007 On Thursday 28 June 2007, Phil Carmody wrote:> --- Roy.Johnsonshell.com wrote:> > Mine (borrowing RJK&39;s testing code): $1 will be the last letter> > (non-underscore) before or at the target location; $2 will be the first> > letter at or after the target location, or the last letter if no such> > letter exists.> >> > for (qw A_Z_K_ A_____ _____K ) > > print "$_n";> > for my $n (1 .. 6) > > my $r = $n - 1;> > ..http://www.nntp.perl.org/group/perl.golf/2007/06/msg2476.html RE: regexp quickie by Phil Carmody- June 27, 2007 --- Roy.Johnsonshell.com wrote:> Mine (borrowing RJK&39;s testing code): $1 will be the last letter> (non-underscore) before or at the target location; $2 will be the first> letter at or after the target location, or the last letter if no such letter> exists.> > for (qw A_Z_K_ A_____ _____K ) > print "$_n";> for my $n (1 .. 6) > my $r = $n - 1;> print "$n: ";> print (=.0,$r(_)).0,$r.(_)> "$1 ($2)" :...http://www.nntp.perl.org/group/perl.golf/2007/06/msg2475.html RE: regexp quickie by Roy.Johnson- June 27, 2007 > If you want $2 to only ever be the first letter at or after the target> location, you can just tweak the second half of the regex:> > (=.0,$r(_))(:.$r.(_))Save a stroke: (=.0,$r(_))(:.$r,(_))Royhttp://www.nntp.perl.org/group/perl.golf/2007/06/msg2474.html Re: regexp quickie by Ronald J Kimball- June 27, 2007 On Wed, Jun 27, 2007 at 02:26:35PM -0500, Roy.Johnsonshell.com wrote:> Mine (borrowing RJK&39;s testing code): $1 will be the last letter> (non-underscore) before or at the target location; $2 will be the first> letter at or after the target location, or the last letter if no such> letter exists.> > for (qw A_Z_K_ A_____ _____K ) > print "$_n";> for my $n (1 .. 6) > my $r = $n - 1;> print "$n: ";> print...http://www.nntp.perl.org/group/perl.golf/2007/06/msg2473.html RE: regexp quickie by Roy.Johnson- June 27, 2007 Mine (borrowing RJK&39;s testing code): $1 will be the last letter (non-underscore) before or at the target location; $2 will be the first letter at or after the target location, or the last letter if no such letter exists.for (qw A_Z_K_ A_____ _____K ) print "$_n"; for my $n (1 .. 6) my $r = $n - 1; print "$n: "; print (=.0,$r(_)).0,$r.(_) "$1 ($2)" : "no match"; print "n";http://www.nntp.perl.org/group/perl.golf/2007/06/msg2472.html Re: regexp quickie by Phil Carmody- June 27, 2007 --- Ronald J Kimball <rjk-perl-golftamias.net> wrote:> On Wed, Jun 27, 2007 at 05:45:54AM -0700, Phil Carmody wrote:> > Say I had a string satisfying A-Z_6$, but not equal to &39;______&39;> > and I wish to extract from that the 1 or 2 letters which are closest to> > the n-th character in the string. Is there a simple regexp to perform> > that task> > Well, I wouldn&39;t exactly call this regex simple... But I have come up with> one that does it:......http://www.nntp.perl.org/group/perl.golf/2007/06/msg2471.html Re: regexp quickie by Ronald J Kimball- June 27, 2007 On Wed, Jun 27, 2007 at 05:45:54AM -0700, Phil Carmody wrote:> Say I had a string satisfying A-Z_6$, but not equal to &39;______&39;> and I wish to extract from that the 1 or 2 letters which are closest to> the n-th character in the string. Is there a simple regexp to perform> that task> > e.g.> if the string=A_Z_K_ then:> if n=1, then I want &39;A&39; (or &39;AA&39;, not fussed)> if n=2, then I want &39;AZ&39;> if n=3, then I want &39;Z&39; (or &39;ZZ&39;, not...http://www.nntp.perl.org/group/perl.golf/2007/06/msg2470.html regexp quickie by Phil Carmody- June 27, 2007 Say I had a string satisfying A-Z_6$, but not equal to &39;______&39; and Iwish to extract from that the 1 or 2 letters which are closest to the n-thcharacter in the string. Is there a simple regexp to perform that taske.g.if the string=A_Z_K_ then:if n=1, then I want &39;A&39; (or &39;AA&39;, not fussed)if n=2, then I want &39;AZ&39;if n=3, then I want &39;Z&39; (or &39;ZZ&39;, not fussed)if n=4, then I want &39;ZK&39;if n=5 or 6, then I want &39;K&39; (or &39;KK&39;, not fussed)I can see how..http://www.nntp.perl.org/group/perl.golf/2007/06/msg2469.html |