Executing Multiple Saved Regular Expressions

41 views
Skip to first unread message

Peter Kaufman

unread,
Jan 5, 2022, 6:12:09 PM1/5/22
to bbe...@googlegroups.com
Folks,

I couldn't find this in the documentation.

BBEdit version 13.5.7 (415124, 64-bit Intel, sandboxed)
Mac OSX 11.6.1 (Big Sur)

I have stored over 2 dozen regular expressions stored under the "g" in Find/Replace.
I'd like to run 6 of them sequentially against a file.  Is there a way to do this?

Thanks very much in advance!

Peter

--
-------------------------------------------------------------
Peter Kaufman     PKau...@GMail.Com
United States of America
-------------------------------------------------------------

François Schiettecatte

unread,
Jan 5, 2022, 6:17:10 PM1/5/22
to bbe...@googlegroups.com, Peter Kaufman
Peter

Have you looked at Text Factories at all? It looks like they might fit the bill.

Cheers

François
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/CAHrvKty8xxkZhAJwn%3DpFSkLwPR7cy9ZjR99g0%2BCnDyk%3DKgGTZg%40mail.gmail.com.

Patrick Woolsey

unread,
Jan 5, 2022, 6:18:31 PM1/5/22
to bbe...@googlegroups.com
On Jan 05, 2022, at 18:03, Peter Kaufman <pkau...@gmail.com> wrote:

> I couldn't find this in the documentation.
>
> BBEdit version 13.5.7 (415124, 64-bit Intel, sandboxed)
> Mac OSX 11.6.1 (Big Sur)
>
> I have stored over 2 dozen regular expressions stored under the "g" in Find/Replace.
> I'd like to run 6 of them sequentially against a file. Is there a way to do this?


A _text factory_ which contains a suitable set of 'Replace All' actions should do just what you want. :-)

To get started, please see the "Text Factories" section in Chapter 5 of the PDF manual (starts on pg. 145 of the current edition).


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <https://www.barebones.com/>


Fletcher Sandbeck

unread,
Jan 5, 2022, 6:19:45 PM1/5/22
to bbe...@googlegroups.com
You can do this with a Text Factory. Create one from the File > New menu and then add your search/replace operations using several Replace All actions. Use the Choose button to select the open text window you want to do the replacements in and then hit the Play button.

[fletcher]


On Jan 5, 2022, at 3:03 PM, Peter Kaufman <pkau...@gmail.com> wrote:

Peter Kaufman

unread,
Jan 5, 2022, 7:11:47 PM1/5/22
to bbe...@googlegroups.com
François, Patrick and Fletcher, you gentlemen are amazing!  Fast and accurate!  Thank you - I will pursue Text Factory.

Peter


Christopher Stone

unread,
Jan 6, 2022, 7:12:15 AM1/6/22
to BBEdit-Talk
On Jan 05, 2022, at 17:03, Peter Kaufman <pkau...@gmail.com> wrote:
I have stored over 2 dozen regular expressions stored under the "g" in Find/Replace.
I'd like to run 6 of them sequentially against a file.  Is there a way to do this?


Hey Peter,

While Text Factories work well, I tend to use AppleScript for this sort of task.



tell application "BBEdit"
    tell front text document's text
        replace "Match-Pattern-1" using "Replace-Pattern" options {search mode:grep, case sensitive:false, starting at top:true}
        replace "Match-Pattern-2" using "Replace-Pattern" options {search mode:grep, case sensitive:false, starting at top:true}
    end tell
end tell



I find a AppleScripts easier to manage and work with than Text Factories.


--
Best Regards,
Chris

Peter Kaufman

unread,
Jan 6, 2022, 9:07:23 AM1/6/22
to bbe...@googlegroups.com
Thanks, Chris!  I'll try that too!  Love learning new tools!!

Peter



Sent from my Verizon, Samsung Galaxy smartphone
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages