I fail to find the correct GREP for a seemingly very easy query: within an "abc" string, find "b" (without "a" or "c"). As simple as this.
Here are the details: I have a text with many occurrences of this sequence:
~hl xxx
~he xxx
~hd xxx
~hf xxx
~hb xxx
That is, five consecutive paragraphs, each beginning with a code consisting of a tilde (~) followed by h[ledfb] and a space, and then any characters follow (here represented by xxx). The same codes appear in other sequences as well.
Now in such a sequence (and only in such), the paragraph beginning with ~hf should become the second, so that the sequence is changed to:
~hl xxx
~hf xxx
~he xxx
~hd xxx
~hb xxx
I am planning to use a combination of Positive Lookbehind / Positive Lookahead search. This should find each paragraph beginning with "~hf ", only if it occurs after the three paragraphs and before the one paragraph mentioned above. I could then copy the match to the clipboard and move it to the correct place. So I was trying to use this grep:
(?<=hl [^\~]+\r\~he [^\~]+\r\~hd [^\~]+\r)\~hf [^\~]+\r(?=\~hb[^\~]+\r)
The [^\~]+ bits make sure no other code is being matched.
For some reason this does not match anything. Why? (If I omit the lookbehind and lookahead bits, it works.)
Any help greatly appreciated!
Message was edited by: samar02