22380RE: [NTB] Regular Expression: find between two words
- Feb 23 11:44 AMI don't think that \R will work properly in a negated class in all cases. It is a character class, and \R can include
more than one character. I have had a number of errors occur because of this. It is better to use \r\n, as neither of
those characters will then be included. If you can't duplicate it, just trust me � under certain circumstances, you can
end up with single character line ends, when you expect the Windows standard, of \r\n.
As this is actually a clip issue, I copied the clip group, where any further discussion of this functionality should be
continued, for the benefit of other clippers.
RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/
From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Eb
Sent: Thursday, February 23, 2012 11:21
Subject: Re: [NTB] Regular Expression: find between two words
I think you probably just want the text between the two words. That would require a search phrase like:
"(?<=Word1 )[^\R]*(?= Word2)"
In the search menu, you will not need the quotes.
This expression is one of the most useful ways to use regular expressions, so I added a bit of explanation below (note
the order of the explanations is different from the order of the expressions):
1. "(?<=Word1 )" finds this word (and a following space) as a LEFT anchor (<=) to the desired text, but does not include
it in the match.
3. "(?= Word2)" is the RIGHT anchor to the target text, and will not be included. See NoteTab's Help on regular
expressions, and look for "Assertions".
2. "[^\R]*" between the two anchors searches for any and all character other than a newline sequence. Without the neline
exclusion, the search may find Word2 on some other line, and include everything up to THAT Word2, instead of the one on
the line you're interested in.
If you're going to learn anything about regular expressions, THIS is the one I would recommend.
--- In firstname.lastname@example.org <mailto:notetab%40yahoogroups.com> , Don <don@...> wrote:
> Hit find and then tick the regular expression box and then search for this:
> Word1 (.*) Word2
> That will find it and assign it to a temporary spot where if you were
> using a replace you could insert it with $1.
> On 2/23/2012 12:42 PM, book7reader wrote:
> > Hello,
> > I want to find any text or numbers that exist between two words (the two words are always present in the line but
what is between the changes.) For example in the line...:
> > "Word1 some text or numbers-2 here Word2"
> > ...I want to find:
> > " some text or numbers-2 here " portion of the text based on the "Word1" and "Word2" delimiters.
> > Thanks for your help,
> > James
[Non-text portions of this message have been removed]
- << Previous post in topic Next post in topic >>