Author Topic: How can I append a prefixion or suffix in many selected lines only once?  (Read 3515 times)

inventec

  • Community Member
  • Posts: 10
  • Hero Points: 0
How can I append a prefixion or suffix in many selected lines only once?

such as follow,
(1)
ALGERIA_213,
AMERICAN_SAMOA_1684,
ANDORRA_376,
ANGOLA_244,
ANGUILLA_1264,
ANTARCTICA_672,
ANTIGUA_AND_BARBUDA_1268,
ARGENTINA_54,
ARMENIA_374,

change to:

_STR_COUNTRY_ALGERIA_213,
_STR_COUNTRY_AMERICAN_SAMOA_1684,
_STR_COUNTRY_ANDORRA_376,
_STR_COUNTRY_ANGOLA_244,
_STR_COUNTRY_ANGUILLA_1264,
_STR_COUNTRY_ANTARCTICA_672,
_STR_COUNTRY_ANTIGUA_AND_BARBUDA_1268,
_STR_COUNTRY_ARGENTINA_54,
_STR_COUNTRY_ARMENIA_374,

(2)
"Algeria(+213)
"American Samoa(+1684)
"Andorra(+376)
"Angola(+244)
"Anguilla(+1264)
"Antarctica(+672)
"Antigua and Barbuda(+1268)
"Argentina(+54)
"Armenia(+374)

change to:

"Algeria(+213)",
"American Samoa(+1684)",
"Andorra(+376)",
"Angola(+244)",
"Anguilla(+1264)",
"Antarctica(+672)",
"Antigua and Barbuda(+1268)",
"Argentina(+54)",
"Armenia(+374)",

help, thank you very much !

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: How can I append a prefixion or suffix in many selected lines only once?
« Reply #1 on: January 16, 2007, 09:49:27 am »
Just use regex replace.
On cmdline using SlickEdit regex syntax - see 'help replace' for further details.
('c' is just a built-in abbreviation for replace)

(1)
c /{^?*}/_STR_COUNTRY_#0/M*

(2)
c /$/",/M*

or if you want to 'stringify' a list w/o any manual interaction.
c /{^?@$}/"#0",/M*

Of course you can use the GUI-based 'Search and Replace' dialog ('Search->Replace').
The 'Tools->Regex Evaluator' is also extremely useful. (avail. since v11)

Good luck,

HS2