Page 1 of 1
Find two words on a line?
Posted: Thu Sep 06, 2012 10:36 pm
by bevhoward
Is there a regular expression that will work within TextPad to find two or more words (strings) on a line that are separated by other words?
For example, find instances in files where "passport" and "expire" are contained in any line such as;
Your passport will expire on...
Tinkered with \W+ but was unsuccessful.
Thanks in advance,
Beverly Howard
Posted: Thu Sep 06, 2012 11:39 pm
by ak47wong
To search for "passport" followed by "expire":
Find what: passport.*expire
To search for "passport" followed by "expire" followed by "renew":
Find what: passport.*expire.*renew
Posted: Fri Sep 07, 2012 12:08 am
by bevhoward
Find what: passport.*expire
DOH!
Thanks!
Beverly Howard
Posted: Fri Sep 07, 2012 7:18 am
by ben_josephs
And to find lines containing
passport and
expire, that is,
passport followed by
expire or
expire followed by
passport:
passport.*expire|passport.*expire
This assumes you are using "Posix" regular expression syntax:
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Posted: Fri Sep 07, 2012 12:32 pm
by bevhoward
This assumes you are using "Posix" regular expression syntax:
Thanks... very useful, but I assumed that achieving that was going to be too much to ask.
Reviewing the default/posix differences, it does not look like setting that will make a difference in my use of searches.
Thanks,
Beverly Howard
Posted: Fri Sep 07, 2012 1:09 pm
by ben_josephs
They differ in the backslash-quoting of |, (, ), { and }.
The regex I suggested has a | in it.