22385Re: [NTB] Regular Expression: find between two words
- Feb 25, 2012Ahhh!
The two (or more) spaces pose a problem. Many computer algorithms interpret multiple spaces as one. NoteTab is confused here. Part of the regex engine sees the first space individually, but another part interprets the two spaces as one. Since that second part does not have a space left in the target string, it cannot match the string.
The easy solution is to include one or more spaces in your match.
If you're ok with including the space in the matches pattern,
i.e. " some text here ", just eliminate the space from the assertion (anchors), and use "(?<=word1)[^\r\n]*(?=word2)". Or "(?<=word1).*(?=word2)"
To eliminate a variable size of white space from the match is very tricky without replacing the original text. Better would be to include 1 space in the assertion, and include any remaining spaces in the matched pattern.
i.e. "(?<=word1 ) *[^\r\n]* *(?= word2)"
The space followed by an asterisk will allow for zero or more spaces.
--- In firstname.lastname@example.org, "book7reader" <jim@...> wrote:
> If this is the actual target text:
> word1 some text here word2
> And I paste in:
> (?<=word1 )[^\r\n]*(?= word2)
> ...and click the Notetabpro Regular Expression check box in Find,
> It does not find " some text here "
- << Previous post in topic Next post in topic >>