<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!
On Sep 14, 2021, at 16:57, Sonic Purity <sonic...@gmail.com> wrote:
Re-reading the Grep help file with BBEdit, i thought lookahead might help. I tried:
<h2>([\s\S]+?)(?<h2>)
<h2>([\s\S]+?)(?<h2>)
On Sep 15, 2021, at 00:51, ctfishman <mfis...@casciac.org> wrote:
I tried doing this with just a regular expression but couldn't figure out how.
I was however able to do it quite easily with a text filter...
--------------------------#!/usr/bin/perl# Read each line into a scaler, then print it backmy $fullstring;while (<>) {$fullstring .= $_;print;}
You miswrote your lookahead-assertion.
Try this instead:(?s)<h2>.+?(?=<h2>|\Z)