Seems simple ... but fails

General questions about using TextPad

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

Post Reply
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

Seems simple ... but fails

Post by terrypin »

Where am I going wrong with this replace please? I want to turn this

Accessibility Controls
access.cpl

Add Hardware Wizard
hdwwiz.cpl

Add/Remove Programs
appwiz.cpl


etc

into this

Accessibility Controls: access.cpl

Add Hardware Wizard: hdwwiz.cpl

Add/Remove Programs: appwiz.cpl


etc


I don't see why this doesn't work:

Find
(.*)\n(.*)\n

Replace with
\1: \2\n


--
Terry, East Grinstead, UK
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You haven't told us it what way it doesn't work.

You haven't told us which version of TextPad you're using.

If you're using version 7, to match the ith captured subexpression you need $i, not \i.

If your pairs of lines are separated by a blank line, as in your example, you need an extra \n.

Try this:
Find what: (.*)\n(.*)\n\n
Replace with: $1: $2\n\n
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

Post by terrypin »

You haven't told us it what way it doesn't work.

It gives this result:
Accessibility Controls: access.cpl
: Add Hardware Wizard
hdwwiz.cpl:
Add/Remove Programs: appwiz.cpl


You haven't told us which version of TextPad you're using.
4.7.2 32 bit

If your pairs of lines are separated by a blank line, as in your example, you need an extra \n.

Thanks, that fixed it!

Find
(.*)\n(.*)\n\n

Replace with
\1: \2\n\n

gave this correct result

Accessibility Controls: access.cpl

Add Hardware Wizard: hdwwiz.cpl

Add/Remove Programs: appwiz.cpl


--
Terry, East Grinstead, UK
Post Reply