Page 1 of 1

Need help creating a Macro

Posted: Wed Feb 11, 2015 2:47 pm
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: (


Posted: Wed Feb 11, 2015 5:17 pm
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

Posted: Wed Feb 18, 2015 4:29 pm
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.

Posted: Wed Feb 18, 2015 5:32 pm
by ben_josephs
What indicates the beginning and end of the list of entries to be enclosed in parentheses?