searching for a text array (logical .or.)

General questions about using TextPad

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

Post Reply
oknef34
Posts: 2
Joined: Thu Oct 13, 2005 9:15 am

searching for a text array (logical .or.)

Post by oknef34 »

Hi Folks,
I want to search for files that have string1 .or. string2 .or. string3 .or. ....
How to do? I could not find it in forum or I search for the wrong words ;-)

Is there a way to have a external table/array for the different search strings?


thanks a lot in advance


Greetings
Oknef
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Using Regular Expression you could try in find in files:
Find what: (string1|string2|string3)
Don't think you can use external tables for the different search strings. HTH
Then I open up and see
the person fumbling here is me
a different way to be
oknef34
Posts: 2
Joined: Thu Oct 13, 2005 9:15 am

thanks but doesn't work

Post by oknef34 »

think it is a problem with the separators for each string, and there is also no .or. possible, so maybe it can't work in textpad. :(
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

Say you have a range of strings as shown below

Code: Select all

banana potato chicken juice
And want to find banana or juice then you need to use the regular expression shown below.

banana\|juice

This should extend to use in find in files
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

It depends on whether you're using Posix regular expression syntax:
Configuration | Preferences | Editor

[ ] Use POSIX regular expression syntax
If you're not, it's \|; if you are, it's |.

By default Posix syntax is not used. But if you expect to use any complex regular expressions, and if you hope to maintain your sanity, I strongly recommend Posix syntax.
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

POSIX Differences

Post by SteveH »

If you're not, it's \|; if you are, it's |.
Checking the TP help file, there seem to be only two differences between POSIX and non-POSIX expression, the one above and {min,max}.

The OR expression above is certainly a lot simpler. Are there other factors that lead to POSIX being a better choice?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Also ( ... ). They're the real killers. Expressions with a lot of parenthesised subexpressions, especially nested ones, and especially when they contain other non-alphanumeric characters, quickly become unreadable with all those escaped parentheses. And it gets worse when you add yet more parentheses to capture subexpressions to use in replacement expressions.

Also, if you intend to get into Perl-style regexes, it's as well to get into the modern style of regex escaping early.
Post Reply