General questions about using TextPad
Moderators: AmigoJack , bbadmin , helios , Bob Hansen , MudGuard
bevhoward
Posts: 27 Joined: Tue Oct 05, 2004 6:38 pm
Location: Austin, Texas, USA
Contact:
Post
by bevhoward » Thu Sep 06, 2012 10:36 pm
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
ak47wong
Posts: 703 Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia
Post
by ak47wong » Thu Sep 06, 2012 11:39 pm
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
bevhoward
Posts: 27 Joined: Tue Oct 05, 2004 6:38 pm
Location: Austin, Texas, USA
Contact:
Post
by bevhoward » Fri Sep 07, 2012 12:08 am
Find what: passport.*expire
DOH!
Thanks!
Beverly Howard
ben_josephs
Posts: 2461 Joined: Sun Mar 02, 2003 9:22 pm
Post
by ben_josephs » Fri Sep 07, 2012 7:18 am
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:
C onfigure | P references | Editor
[X ] Use P OSIX regular expression syntax
bevhoward
Posts: 27 Joined: Tue Oct 05, 2004 6:38 pm
Location: Austin, Texas, USA
Contact:
Post
by bevhoward » Fri Sep 07, 2012 12:32 pm
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
ben_josephs
Posts: 2461 Joined: Sun Mar 02, 2003 9:22 pm
Post
by ben_josephs » Fri Sep 07, 2012 1:09 pm
They differ in the backslash-quoting of | , ( , ) , { and } .
The regex I suggested has a | in it.