Page 1 of 1

wildcard characters

Posted: Thu Jan 04, 2007 4:52 pm
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

Posted: Thu Jan 04, 2007 8:27 pm
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

Posted: Thu Jan 04, 2007 9:14 pm
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 =.

Posted: Thu Jan 04, 2007 9:24 pm
by ben_josephs
He's using Find In Files to find the lines the strings occur in. For this purpose it makes no difference.

Posted: Wed Jan 10, 2007 9:56 pm
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 :)

Posted: Wed Jan 10, 2007 9:58 pm
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?

Posted: Wed Jan 10, 2007 10:45 pm
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.

Posted: Wed Jan 10, 2007 10:46 pm
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.

Posted: Thu Jan 11, 2007 12:46 pm
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.