As Massimo Rainato suggested, you can use a text factory consisting of a
"Run Unix Command" action with the "Options..." set to:
perl -pi -e '!$subbed{$ARGV} and s/<section>/<section id=“main_content">/
and $subbed{$ARGV}++'
That isn't the most elegant perl one liner, but it works to find the first
line in a file (and only that first occurrence) containing the matching
<section> and substitute that match with <section id=“main_content">.
For the files and/or folders you want to apply the text factory to, click
on the text factory's "Choose..." button and make your selections. (The
text factory's "Options..." button will open a dialog for specifying file
filters, nested folder handling, and file changed options.)
On Thursday, May 7, 2026 at 6:29:51 AM UTC-7 Neil Faiman wrote:
> Well, at least I read the fine manual and saved myself the humiliation of
> publicly asking whether there was a way to selectively search in the set of
> files that matched a previous multi-file search. (Of course there is. Just
> select the previous search results from the “Results Browsers” list in the
> “Search in:” chooser.)
>
> But I couldn’t find this one in the manual. I have a bunch of HTML files.
> Some of them have multiple <section> elements. I want to add a property to
> the first <section> tag in each file. I.e., before
>
> <section>
> some content
> <section>
> inner content
> </section>
> </section>
> <section>
> more content
> </section>
>
>
> and after:
>
> <section id=“main_content">
> some content
> <section>
> inner content
> </section>
> </section>
> <section>
> more content
> </section>
>
>
> But the only choices seem to be replace al or replace none. Is there a
> clever hack to solve this (or better, another feature I’ve overlooked?
>
> Thanks,
> Neil Faiman
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or believe that the application isn't working correctly, please email
"[email protected]" rather than posting here. Follow @bbedit on Mastodon:
<https://mastodon.social/@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 view this discussion visit
https://groups.google.com/d/msgid/bbedit/26744e40-6ee2-41a8-b93f-771ddb47f40en%40googlegroups.com.