Need help creating a Macro

General questions about using TextPad

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

Post Reply
ravilobo
Posts: 18
Joined: Fri Dec 14, 2007 8:45 pm

Need help creating a Macro

Post by ravilobo »

I need little help in creating a macro. The regex works as expected. But when I try to put it in a macro, it doesn’t work.

This is one column of data:

Code: Select all

C0031
C1376

F189

F912
This is how I want the data to look like.

Code: Select all

('C0031', 'C1376', 'F189', 'F912')

Here are the steps I follow. They work perfectly, except in a macro. What I’m doing wrong?

Code: Select all

find: $\n^$
replace:

find: ^(.*)$
replace: '\1',


find: \n
replace:

find: ,$	
replace:)


find: ^
replace: (

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

Post by ben_josephs »

I don't know.

But it appears you are using an old version of TextPad. You could upgrade to the latest version of TextPad and try this:
Find what: (.+)\n+(.+)\n+(.+)\n+(.+)
Replace with: \('$1', '$2', '$3', '$4'\)

[X] Regular expression

Replace All
ravilobo
Posts: 18
Joined: Fri Dec 14, 2007 8:45 pm

Post by ravilobo »

ben_josephs wrote:
Find what: (.+)\n+(.+)\n+(.+)\n+(.+)
Replace with: \('$1', '$2', '$3', '$4'\)
Thank you Ben.
Your code works only for 4 entries. I need a generic solution, where it should work, even if i enter 100 entries.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

What indicates the beginning and end of the list of entries to be enclosed in parentheses?
Post Reply