Adding Quotes on Selective Lines

Help with writing and playing macros

Adding Quotes on Selective Lines

Postby asjones » Wed Nov 08, 2006 5:49 pm

I have a series of lines, names and address type stuff that came out in a funky format. To now import them into another system I need to put quotes (" ") around all the lines EXCEPT first and last line in a series.

Each series is separated by 1 or 2 blank lines

I am using the latest UltraEdit 12.20a+2 and could not figure out a viable regular expression yet based on what I have seen it seems like there should be one with the new Perl compatible engine.

thanks for any help and ideas

Alan


Sample:

sdfsa, bas,fsdf,adf,adsfafds,asdf,
ddflk,asd,df
sadfasdf,sadf,sdf
sadsadf,adfs,adsf


df adsf,sadf,asdf,sadf,sadf,
32 das fadf,adf
sa,df sadf

asdd fad fasdfasdfasdf,asd
23324 dsaf
3232,adfs,sadf,dsd
233223,4sd,asdf,sad
2323sd,dsf ,,dsfadfasdfsadf



sdfsa, bas,fsdf,adf,adsfafds,asdf,
ddflk,asd,df
sadfasdf,sadf,sdf
sadsadf,adfs,adsf


df adsf,sadf,asdf,sadf,sadf,
32 das fadf,adf
sa,df sadf

asdd fad fasdfasdfasdf,asd
23324 dsaf
3232,adfs,sadf,dsd
233223,4sd,asdf,sad
2323sd,dsf ,,dsfadfasdfsadf



Turn the above into:


sdfsa, bas,fsdf,adf,adsfafds,asdf,
"ddflk,asd,df"
"sadfasdf,sadf,sdf"
sadsadf,adfs,adsf


df adsf,sadf,asdf,sadf,sadf,
"32 das fadf,adf"
sa,df sadf

asdd fad fasdfasdfasdf,asd
"23324 dsaf"
"3232,adfs,sadf,dsd"
"233223,4sd,asdf,sad"
2323sd,dsf ,,dsfadfasdfsadf
User avatar
asjones
Newbie
 
Posts: 3
Joined: Mon Jul 26, 2004 11:00 pm

Re: Adding Quotes on Selective Lines

Postby Mofi » Thu Nov 09, 2006 2:58 pm

Very good, you have posted your UltraEdit version and a before and after example. So it was no problem for me to write a macro for this job:

InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
IfColNum 1
"
"
Else
"

"
EndIf
Top
"

"
TrimTrailingSpaces
Top
Find RegExp "%^([~^p]*^)$"
Replace All ""^1""
Find RegExp "^p^p"^(*^)"$"
Replace All "^p^p^1"
Find RegExp "%"^([~"]+^)"^p^p"
Replace All "^1^p^p"
Bottom
DeleteLine
Top
DeleteLine
DeleteLine

Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4051
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros