wildcard characters

General questions about using TextPad

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

Post Reply
Dtsig
Posts: 23
Joined: Mon Mar 17, 2003 8:29 pm

wildcard characters

Post by Dtsig »

Using findInFiles i am trying to find all instances of a specific string regardless of some characters. Here is an example line

IF INVENTORY.REC(III+14)<1,PURCHASE.ORDERS.WHSE.NO>=0 THEN INVENTORY.REC(III+14)<1,PURCHASE.ORDERS.WHSE.NO>=""

I have found all lines with INVENTORY.REC( using the string 'INVENTORY(" but i would like to find all lines with assignements so something like

INVENTORY.REC(?)<?>=

where i want to ignore any characters where the ? is

I would also like to know if there is any way to ignore all spaces. so lines like

IF INVENTORY.REC(III+14)<1,PURCHASE.ORDERS.WHSE.NO>=0

might be

IF INVENTORY.REC(III+14)<1,PURCHASE.ORDERS.WHSE.NO> = 0
DTSig
David Tod Sigafoos
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You need to use regular expressions, in which certain characters have special meanings:
“.� (dot) matches any single character except newline.
“.*� matches any number of characters except newline.
“ *� (there's a space in front of the “*�) matches any number of spaces.

When you want one of the special characters to represent itself you must quote it with a backslash. In particular, when using Posix syntax (see below), “.�, “(� and “)� must be quoted when they represent themselves.

So this might be what you need:
Find what: INVENTORY\.REC\(.*\)<.*> *= *

[X] Regular expression
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

You also need to be aware that TextPad will find the longest match possible on each line. This means that using the example you gave ben_josephs search expression will match from the first INVENTORY to the second =.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

He's using Find In Files to find the lines the strings occur in. For this purpose it makes no difference.
Dtsig
Posts: 23
Joined: Mon Mar 17, 2003 8:29 pm

Post by Dtsig »

ben_josephs wrote:You need to use regular expressions, in which certain characters have special meanings:
“.� (dot) matches any single character except newline.
“.*� matches any number of characters except newline.
“ *� (there's a space in front of the “*�) matches any number of spaces.

When you want one of the special characters to represent itself you must quote it with a backslash. In particular, when using Posix syntax (see below), “.�, “(� and “)� must be quoted when they represent themselves.

So this might be what you need:
Find what: INVENTORY\.REC\(.*\)<.*> *= *

[X] Regular expression
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
I find the following line appears in the results list. No where is there an INVENTORY.REC()<>=


WL.UPDATE.LOCATION.PIK(193): IF INVENTORY.SIZE.TYPE=99 OR (INVENTORY.REC(III+4)<1,WHSE.NO>+0)#0 OR INVENTORY.LOCS.REC(III)<1,1>#"" OR INVENTORY.LOCS.REC(III)<1,2>#"" OR INVENTORY.LOCS.REC(III)<1,3>#"" OR INVENTORY.LOCS.REC(III)<1,4>#"" THEN INVENTORY.STOCKED<1,WHSE.NO>=1;III=5

mostly works and is a great first step. thanks

what is the difference with postix ? (if it is quick :)
Last edited by Dtsig on Wed Jan 10, 2007 10:13 pm, edited 1 time in total.
DTSig
David Tod Sigafoos
Dtsig
Posts: 23
Joined: Mon Mar 17, 2003 8:29 pm

Post by Dtsig »

SteveH wrote:You also need to be aware that TextPad will find the longest match possible on each line. This means that using the example you gave ben_josephs search expression will match from the first INVENTORY to the second =.
so what you are saying is that if i was in a specific record and did that selection it would select all rows from INVENTORY to the second =

Is this right?
DTSig
David Tod Sigafoos
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Dtsig wrote:I find the following line appears in the results list. No where is there an INVENTORY.REC()<>=
Do you mean that there is to be no > between the < and the > ? You didn't make that clear. This imposes that restriction:
INVENTORY\.REC\(.*\)<[^>]*> *= *

What other restrictions do you want to impose?
Dtsig wrote:what is the difference with postix ?
Search in TextPad's help for Posix.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Dtsig wrote:
SteveH wrote:You also need to be aware that TextPad will find the longest match possible on each line. This means that using the example you gave ben_josephs search expression will match from the first INVENTORY to the second =.
so what you are saying is that if i was in a specific record and did that selection it would select all rows from INVENTORY to the second =

Is this right?
No. It will only match text on a single line. The search expression must include explicit newlines (\n) for TextPad to match text on more than one line. But, once it's found a position within a line at which there is a match, it will match the longest possible string that starts at that position. This is related to the fact that my original suggestion matched too much. If that's what Steve meant, I apologise for missing his point.
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

If that's what Steve meant, I apologise for missing his point.
That was what I meant but, as you said, for the purposes of using Find in Files as per Dtsig's original query it makes no difference.
Post Reply