I'm trying to find everything between two words (not going to say which two words because I don't want people screaming "you can't parse x with regexes, use an x parser instead). I have no trouble finding the start word and the end word - except that the end word isn't the first one encountered.
What I'm using is something like: startword((.*\n)*)endword
This isn't as bad as leaving off the endword, which then matches to the end of the document. However it's not what I need.
I've read umpteen articles saying what I want is a non-greedy or lazy search that should be turned on by putting a ? after the **. When I try that in KATE, it matches nothing (startword((.*\n)*?)endword
).
I'm also puzzled by another behaviour - I have some text where endword\n\s**endword occurs but when I use that to end the match, it also fails. However the match endword\n\s*endword by itself operates as expected.
Is there a way to do lazy regexes in KATE, or can anyone come up with another solution?
Thanks.
For some reason (probably related to my inadequate understanding of regexes), something I tried earlier finally worked. Rather than having an indefinite number of lines between the start word and the end word, I was able to specify it as an indefinite number of lines in the form
(startword2.*endword2)*
This removed the need to do a lazy evaluation.