22151Re: [Clip] A little help on look behinds
- Oct 15, 2011I'm using 6.2 and it works on your sample. You might want to add a
prompt to tell you when its done.
It will never remove more than one, but I suppose it would be more
efficient to omit the "A" option. Same difference in result without it,
but after the single replacement, it doesn't need to travel through the
rest of the document futilely looking for another \A
^!Replace "(?s)\A.+?\R\K(?=\]\]\]|\[\[\[)(*COMMIT)(?-s)\]\]\].*\R">> "" WRS
It is requiring the ]]] or [[[ to be at the start of a line (and cannot be the first line) as that was my understanding from this and previous samples. So even if your entire message with the explanatory paragraph above the sample is in the document, only the one line in the sample portion is removed.
To be clear, here is what the pattern does:
consumes all characters from the very beginning of the (Whole) document until it sees ahead a line that begins with ]]] or [[[
At that point the rest of the pattern must match or there is no match and no backtrack. The critical rest of the pattern is ]]] plus any characters up to the end of the line plus a line break.
If there is match, the \K excludes all the text from the beginning of the text up to the beginning of the ]]] line from being part of the text that gets deleted.
There can only ever be one match anchored to the start of the text \A (even with All option).
If there was another ]]] line before a [[[ one, you would have to run the clip line again to get it (even if you had the "A" (replace All) option.
- << Previous post in topic Next post in topic >>