Regular expression help

General questions about using TextPad

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

Post Reply
Brian Jackson

Regular expression help

Post by Brian Jackson »

Hi,

I'm hoping that someone will have a suggestion for me because I've been working with the regular expressions descriptions over and over, and I can't figure out how to make double-click "jump-to's" work in the command results window with my compiler.

My compiler generates messages like this:

...
148. INCLUDE T: qryrailcarstatcentrespa00.inc
149. INCLUDE U: qryrailcarstatloclrespa00.inc
150. INCLUDE V: qryrailcarvinrespa00.inc
151. INCLUDE W: qrytrkrespa00.inc
152. INCLUDE X: qryvinramposrespa00.inc
153. INCLUDE Y: qryvinreqbayrespa00.inc
154. INCLUDE Z: sbmtadhocrespa00.inc
155. INCLUDE AA: sbmtasnrespa00.inc
156. INCLUDE AB: sbmtvingateactrespa00.inc
...

There are two things going on here. First of all, most of the lines just refer to include files. I'd like to be able to double-click on the file names and open those files. Thus far, I've not been able to figure out how to write a regular expression to do this. Can anyone be of any help with this?

Thanks in advance,
Brian
Ed Orchard

Re: Regular expression help

Post by Ed Orchard »

Assuming the qryrailcarstatcentrespa00.inc etc are filenames in the current directory and that the error line always starts with a number and has ": " before the filename then the following reg expression should work with "File:" set to 1

^[0-9]+. [^:]+: \([.[:alnum:]]+\)

...or have I missed the point?
Brian Jackson

Re: Regular expression help

Post by Brian Jackson »

Ed,

Thank you very much. The expression ^[0-9]+. [^:]+: \([.[:alnum:]]+\) was almost exactly what I needed. Since there may be leading spaces in the numeric string, I changed the ^[0-9] part of the expression to ^.*[0-9], and since underscore and other such characters may appear in the filenames, I changed [:alnum:] to [:print:]. The resulting expression is:

^.*[0-9]+. [^:]+: \([.[:print:]]+\)

Everything is working just as it should now. Thank you very much for your help.

Brian
Carlyle Sutphen

Re: Regular expression help

Post by Carlyle Sutphen »

Hi, Brian,

to take care of leading spaces, it would be more correct to use:

^[ ]*[0-9]+. [^:]+: \([.[:print:]]+\)

since the period matches anything including the numbers.

Carlyle
Post Reply