Misread that part.  Try this:

(?<=<h2>)([\s\S]+?)(?=<h2>)

Cheers


> On 2021-09-15, at 13:15, Sonic Purity <[email protected]> wrote:
> 
> Thank you, but all that does for me is select that one entire chapter 
> heading, not the entire chapter heading plus all the paragraphs of text 
> below. In other words in my example that string selects Exciting Chapter 
> Title Here, but nothing else.
> 
> On Tuesday, September 14, 2021 at 4:03:49 PM UTC-7 Tom Robinson wrote:
> Try this, using positive lookahead and lookbehind assertions:
> 
> (?<=<h2>).+(?=</h2>)
> 
> Cheers
> 
> 
>> On 2021-09-15, at 09:57, Sonic Purity <[email protected] 
>> <applewebdata://A6C63D95-3E41-4ED7-95BF-72B46478D9D2>> wrote:
>> 
>> My fiction writing workflow initially produces one HTML document with the 
>> entire novel’s content. Each chapter starts with <h2>Exciting Chapter Title 
>> Here</h2> then many paragraphs of story text with arbitrary HTML markup. I 
>> split each chapter into its own HTML page, containing everything from that 
>> first <h2> with the chapter title through the end of the chapter, which is 
>> always immediately before the subsequent opening <h2> for the following 
>> chapter (in the original un-split document).
>> 
>> Working manually, i’ve been using the Grep Find:
>> <h2>([\s\S]+?)<h2>
>> 
>> This works perfectly, other than it includes the <h2> at the start of the 
>> next chapter in the selection i’m about to cut or copy into a new HTML 
>> document. I manually back off the selection to include everything found 
>> minus that ending <h2>. I would like to better automate my workflow, but 
>> can’t with the need for this manual adjustment.
>> 
>> Re-reading the Grep help file with BBEdit, i thought lookahead might help. I 
>> tried:
>> 
>> <h2>([\s\S]+?)(?<h2>)
>> 
>> but that just finds the first <h2> and one character immediately following 
>> it. Noticing that BBEdit is highlighting the < for that second <h2>, i tried 
>> escaping it:
>> 
>> <h2>([\s\S]+?)(?\<h2>)
>> 
>> This throws a PCRE error: unrecognized character after (? or (?- (12)
>> 
>> Can anyone suggest a search string that will accomplish my goal?
>> 
>> (BBEdit 11.6.8 running under macOS 10.12.6 Sierra.)
>> 
>> Thanks!
>> 

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/F8B467E3-9DF4-493B-8F39-33D76B616B34%40gmail.com.

Reply via email to