non-greedy matching

General questions about using TextPad

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

Post Reply
james deen
Posts: 3
Joined: Wed Jul 09, 2008 10:51 pm

non-greedy matching

Post by james deen »

Can someone tell me how i can perform non-greedy matching using textpad?
for example, I'd like to change my pattern from

Code: Select all

abc.*def
to

Code: Select all

abc.*?def
to turn it into a non-greedy pattern.
However, this doesn't appear to work.
Do i need to escape the '?' symbol?

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

Post by ben_josephs »

Unfortunately, non-greedy matching isn't available in TextPad, which uses a rather old and weak regular expression recogniser. It is available in WildEdit (http://www.textpad.com/products/wildedit/), though.

If there happen to be specific characters you don't want to occur in a match for the non-greedy part, say, for example, < and >, you may be able get a similar effect with this:
abc[^<>]*def
Otherwise, using TextPad regular expressions alone, you're stumped, I'm afraid.
james deen
Posts: 3
Joined: Wed Jul 09, 2008 10:51 pm

Post by james deen »

Thanks for your response.
That's a shame.
The example you give will work in some simple situations, but not for the cases i have in mind - i'd really need proper non-greedy matching.
I could potentially write an external tool to do the pattern matching but i wouldn't know how to select/highlight the next match.
Using DDEOPN32.EXE, i can (at best) position the cursor beside a match, but it wouldn't highlight it properly, and therefore isn't such a great solution.
Are there any tools other than DDEOPN32.EXE, or are there any other means of externally getting textpad to highlight certain characters in a file?
Thanks
Post Reply