Find two words on a line?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
bevhoward
Posts: 27
Joined: Tue Oct 05, 2004 6:38 pm
Location: Austin, Texas, USA
Contact:

Find two words on a line?

Post 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
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post 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
User avatar
bevhoward
Posts: 27
Joined: Tue Oct 05, 2004 6:38 pm
Location: Austin, Texas, USA
Contact:

Post by bevhoward »

Find what: passport.*expire
DOH!

Thanks!

Beverly Howard
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
User avatar
bevhoward
Posts: 27
Joined: Tue Oct 05, 2004 6:38 pm
Location: Austin, Texas, USA
Contact:

Post 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
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

They differ in the backslash-quoting of |, (, ), { and }.

The regex I suggested has a | in it.
Post Reply