Page 1 of 1

Seems simple ... but fails

Posted: Sun Sep 22, 2013 11:14 am
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

Posted: Sun Sep 22, 2013 3:41 pm
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

Posted: Sun Sep 22, 2013 5:51 pm
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