Works in TP/not WE?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
User avatar
Mike Olds
Posts: 226
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Works in TP/not WE?

Post by Mike Olds »

Hello,

Here is a case where I do not seem to be able to get this regex to work in WildEdit while it does work in TextPad Search:

Search for:
\.\.\/\.\.\/dhamma\-vinaya\/bd\/dn\/dn\.([0-9][0-9])\.rhyt\.pts\.htm

Replace with:
\.\.\/\.\.\/dhamma\-vinaya\/pts\/dn\/dn\.\1\.rhyt\.pts\.htm

Example:
../../dhamma-vinaya/bd/dn/dn.02.rhyt.pts.htm

What I get from WildEdit:
../../dhamma-vinaya/pts/dn/dn..rhyt.pts.htm

X regular expression
X replacement format
POSIX

Ready to be shown my stupid oversight.
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

WildEdit's regex engine is entirely different from TextPad's. TextPad's is old and weak, WildEdit's is modern and powerful. A notational difference is that in a WildEdit replacement expression, to refer to a captured subexpression of the match, you use $n instead of \n.

Also:
You don't need to escape / in a regex.
You don't need to escape - in a regex outside a character class expression.
You don't need to quote any of . / - in a replacement expression (it's not a regex).

Thus, in WildEdit, you can use
Find what: \.\./\.\./dhamma-vinaya/bd/dn/dn\.([0-9][0-9])\.rhyt\.pts\.htm
Replace with: ../../dhamma-vinaya/pts/dn/dn.$1.rhyt.pts.htm
User avatar
Mike Olds
Posts: 226
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Post by Mike Olds »

Thanks Ben,

I understand what 'replacement format' means now which was one confusing thing. So what if I want to use a regex for replacement? Seems like the alternative is literal.

I am now using WildEdit as my search tool of choice except where I am working in a workspace where all the files are present where I still find the search tool in TextPad the most convenient.

Thanks also for the tutorial on regular expressions. Learning Regular Expressions may seem like a simple thing, but I think it is as difficult as learning a simple foreign language in one's old age. Unless I actually go through an issue it is the devil to remember all the rules. Without the Clip Library I would be lost, which is why I would urge the inclusion of such in the next version of WE.
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I don't understand what you mean by "use a regex for replacement".

What is your requirement?
User avatar
Mike Olds
Posts: 226
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Post by Mike Olds »

Hello Ben,

I have no specific problem. I'm guessing this is a terminology issue.

What I am thinking is that 'replacement format' is not a regular expression, what if I wanted to use a regular expression for creating the replacement.

...and you are saying that all the functions of a regular expression are covered by the rules for creating a 'replacement format' replacement?
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I'm afraid I still don't understand.

To specify a replacement you need to specify what you want to replace and what you want to replace it with. These two distinct tasks are handled by two distinct items: a regular expression and a replacement expression. The regular expression specifies the character strings you want to replace; the replacement expression specifies what those strings should be replaced by. The replacement can include parts of what it replaces: a $n (\n in TextPad) in the replacement refers to whatever matched the nth parenthesized subexpression of the regular expression.

Please give an example of what you are trying to do.
User avatar
Mike Olds
Posts: 226
Joined: Wed Sep 30, 2009 3:27 pm
Contact:

Post by Mike Olds »

Hello again Ben,

As I said, I have no problem now that you have pointed me in the right direction.

It's very difficult to come down to the level of the completely ignorant.
Thank you, and
Best Wishes,
Obo
http://buddhadust.net/
check out the What's New? Oblog:
http://buddhadust.net/dhammatalk/dhamma ... ts.new.htm
Post Reply