RE: regexp quickie
[email protected] Wed, 27 Jun 2007 14:26:35 -0500
| Newsgroups | perl.golf |
|---|---|
| Message-ID | <A3B4E948E728054CAC7A6D9C55EAB6A301F713C6@houic-s-348.americas.shell.com> |
Mine (borrowing RJK'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 =3D $n - 1;
print "$n: ";
print /^(?=3D.{0,$r}([^_]))?.{0,$r}.*?([^_])/
? "[$1] ($2)" : "no match";
print "\n";
}
}