22386Re: [NTB] Regular Expression: find between two words
- Feb 25, 2012John,
Finding the last ocurrence is the default with regular expressions. If that is undesirable, follow the quantifier '*' with a question mark, i.e. "*?". Then it will find the first occurrence.
If a match can occur multple times on the same line / paragraph, and you want to restrict the match, change the pattern
from "(?<=Word1 )[^\r\n]*(?= Word2)"
to "(?<=Word1 ).*?(?= Word2)"
or "(?<=Word1 ) *.*? *(?= Word2)"
--- In firstname.lastname@example.org, "John Wallace" <johnta1@...> wrote:
> What would it be if you wanted Word1 to the 1st occurance of the Word2?
> It seems to go to the last occurrance of Word2 now.
- << Previous post in topic Next post in topic >>