On 23/01/2013 17:16, Adam Engst wrote:

What I'm trying to do is create a text _factory_ that does a few standard grep replacements, and then calls something else to do this renumbering...So the question becomes, how would such a perl script or AppleScript need to be written to work from within a text _factory_?

I think the question is rather, why not do the whole thing with a Perl text filter? Then your text filter to do the whole lot would be something like the script below. This can be run, with or without a key shortcut, from the Text Filters palette:

#!/usr/bin/perl
my $n = 1; # set n to 1
while (<>) { # read the file line by line
  s~q~q~g; # your “a few standard grep replacements”
  s~x~x~g; # ie. replace all ‘x’ in the line with ‘x’
  s~y~y~g;
  s~a~a~g;
  $n++ if s~\[\*\]:~[$n]~ ;
  # if found [*], replace with [n] and set n to n+1
  print;
}

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