On 17/01/2013 16:10, Adam Engst wrote:
...Thanks, John! I've never learned any perl, so I can't really parse what your script is doing, but it's not doing quite what I need. Take a look at these two files for a before and after view: https://dl.dropbox.com/u/574336/AutoRip-original.md and https://dl.dropbox.com/u/574336/AutoRip-numbered.md
Right, I see what you want now. The text filter below does it for files formatted as AutoRip-original.md. You can save it as arip.pl in your text filters folder. The script will replace the _first_, and only the first, occurrence in the line of «[*]» with «[n]» and add 1 to n every time it does so.

#!/usr/bin/perl
my $n = 1;         # set n to 1
while (<>) {       # read the file line by line
  $n++ if s~\[\*\]:~[$n]~ ;
                   # if found [*], replace with [n] and set n to n+1
  print;           # write the line
}

Let me know if you have any difficulty with it. I think you’ll agree AppleScript looks a little verbose in comparison!

JD

--
--
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>



Reply via email to