On Aug 05, 2016, at 02:23, Terje Bless <[email protected]> wrote: > Thanks for the tip. I hadn't really been aware of Smile and Satimage.osax > before and it looks really useful for a lot of use cases. Will definitely > note that for future needs.
Hey Terje, Here are the main handlers I use with the Satimage.osax. It's syntax is even richer still, but I'll leave that for you to explore. (Message me anytime if you have questions.) ------------------------------------------------------------------------------------------- # Find and Change Handlers for the Satimage.osax (AppleScript Extension). # http://www.satimage.fr/software/en/downloads/downloads_companion_osaxen.html ------------------------------------------------------------------------------------------- set _text to cng("regex", "into", _data) of me set _text to fnd("_find", _data, true, true) of me set _text to fndUsing("_find", "_capture", _data, true, true) of me set _text to fndBool("_find", _data, false, false) of me ------------------------------------------------------------------------------------------- --» HANDLERS ------------------------------------------------------------------------------------------- on cng(_find, _replace, _data) change _find into _replace in _data with regexp without case sensitive end cng ------------------------------------------------------------------------------------------- on fnd(_find, _data, _all, strRslt) try find text _find in _data all occurrences _all string result strRslt with regexp without case sensitive on error return false end try end fnd ------------------------------------------------------------------------------------------- on fndBool(_find, _data, _all, strRslt) try find text _find in _data all occurrences _all string result strRslt with regexp without case sensitive return true on error return false end try end fndBool ------------------------------------------------------------------------------------------- on fndUsing(_find, _capture, _data, _all, strRslt) try set findResult to find text _find in _data using _capture all occurrences _all ¬ string result strRslt with regexp without case sensitive on error false end try end fndUsing ------------------------------------------------------------------------------------------- For changing text in a BBEdit document using my “cng” handler: ------------------------------------------------------------------------------------------- tell application "BBEdit" tell front text document to set _text to its text end tell # Change 01 set _text to cng("yourFindPattern", "yourReplacePattern", _text) of me # Change 02 set _text to cng("yourFindPattern", "yourReplacePattern", _text) of me tell application "BBEdit" tell front text document set its text to _text select insertion point before line 1 end tell end tell ------------------------------------------------------------------------------------------- You can get much more sophisticated of course. > For this one, however, if I can't simply automate the tedious bits of using a > Text Factory I will probably break down and write a Text Filter in Perl for > this (maybe with a bit of AppleScript glue). If you're comfortable with Perl then it's easy. #! /usr/bin/env perl -sw while (<>) { s!\bsecurity\b!••••••••!g; s!\bpassword\b!••••••••!g; print; } Write yourself a little AppleScript (or shell script) for opening the filter file in BBEdit. Give them both keyboard shortcuts. Then you can quickly open the script for editing via the open-script keyboard shortcut and run it with its own keyboard shortcut. I do this frequently with several often used scripts of various kinds. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. 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> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/bbedit.
