You can do this with a search/replace. The first pattern matches the contents 
of the file before the first <section>. [\s\S] is used instead of period so it 
will match without finding the next repetition of the pattern. The question 
mark on the first grouping makes it match the first <section>.

Search pattern: ([\s\S]*?)<section>([\s\S]*)

Replace pattern: \1<section id=“main_content">\2

[fletcher]

> On May 7, 2026, at 6:29 AM, Neil Faiman <[email protected]> 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/0E76497B-0BB8-4AB2-A2B2-C595E261F46F%40faiman.org.

-- 
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/E3C3CFD9-09EE-4CE3-8854-7238E8446121%40cumuli.com.

Reply via email to