On Tue, Nov 23, 2010 at 07:44:27AM +0100, Marek Stepanek wrote:
> On 22.11.2010 23:24, John Delacour wrote:
> > At 21:22 +0100 22/11/2010, you wrote:
>
> > Another way to do it (TMTOWTDI) is to create a UNIX/Perl script and run
> > it on the open document. That way you can undo the result if you screw up:
> >
> >
> > #!/usr/bin/perl
> > while (<>) {
> > m~\d{4}.tif~ and s~(\d)~chr(64+$1)~eg;
> > print;
> > }
> >
> >
> > JD
> >
>
>
> Wow! Very elegant solution. Only problem: $1 = 0 gives back chr(64) = @
>
> Probably better to start with chr(65) :
>
> while (<>) {
> m~\d{4}.tif~ and s~(\d)~chr(65+$1)~eg;
> print;
> }
Be aware that these two solutions replace *all* digits within any line
which matches \d{4}.tif, not just the digits in the filename. Also, the
period needs to be escaped. :)
Here's another way to do it:
#!perl -p
s/(\d{4})(?=\.tif)/ ($x=$1)=~tr,1-90,A-J,; $x /ge;
Ronald
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>