Try this, using positive lookahead and lookbehind assertions:

(?<=<h2>).+(?=</h2>)

Cheers


> On 2021-09-15, at 09:57, Sonic Purity <[email protected]> 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/70D20E25-6152-437F-8167-7F11144FA3D8%40gmail.com.

Reply via email to