Tagged Expressions and Carriage Returns with REs

General questions about using TextPad

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

Post Reply
gordonfj
Posts: 4
Joined: Mon Oct 20, 2003 3:45 pm

Tagged Expressions and Carriage Returns with REs

Post by gordonfj »

In this example text:
blah
A
A
yadda
Is it possible to search for the following:

\(A\)\n\1

Why is this RE invalid?
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

From your RegEx:
\(A\)\n\1
What is the \1 for?
Trying to repeat A? So you are searching for A\nA, is that correct?
I don't think you can use \1 to include a \n with TextPad RegEx.
\(A\)\n
works OK by itself. Finds three lines unless you select to match case, and then it only finds 2 lines, just as it should.

If I use \1 as replacement for A\n, it works OK, I end up with AA\n, but it does not translate correctly in the search mode. Expression \1 cannot be found.
Hope this was helpful.............good luck,
Bob
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Textpad is quite weak on multiline RegExes.

(A)\1 finds AA as expected, but (A)\n\1 does not find A\nA as the \1 is in a different line as the ()

Workaround:
first, replace \n by a string not existing in the document, e.g. @@@

Then do your replacement searching for (A)@@@\1

When finished, replace your string from step 1 (@@@ in the example) by \n again.
gordonfj
Posts: 4
Joined: Mon Oct 20, 2003 3:45 pm

Post by gordonfj »

Thanks for the help Muguard. Thats what I was expecting.
I'd like the RE handling in TP to be able to handle multiple lines.

Do you know if this is in the development pipeline?
Post Reply