[thelist] Dreamweaver REGEX Find and Replace help.

Ricky Zhou ricky.zhou at gmail.com
Fri Jul 13 11:44:05 CDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jon Hughes wrote:
> Item1, item2, item3
> "Add #84FD. to this item","Put 7 #HH23. to this item,"Needs 9 #HH47."
> 
> I am trying to make it this:
> 
> Item1, item2, item3
> "#84FD","#HH23","#HH47"
I'm not using Dreamweaver, but here are the commands I'd use in Vim
(hopefully they're somewhat analogous):

:%s/\(#.\{4}\)/(\1)/g       Replace #.... with (#....)
:%s/^.\{-}(/"/              Remove any junk from the beginning
:%s/).\{-}(/","/g           Remove any junk in between ) and (
:%s/).*/"/                  Remove any junk at the end

Somebody with better Vim/regex skills would probably be able to reduce
this into one nicer command, and this might fail in certain cases (I
only tested on that single line of data).

Here's a "guess" for how it might look in less a Vim-specific context
(it should work in Perl, at least):
s/(#.{4})/\($1\)/g
s/^.*?\(/"/
s/\).*?\(/","/g
s/\).*/"/

Hope this helps,
Ricky
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFGl6vTZBKKLMyvSE4RAsOuAJ0csk2TEvuT3WBJAoqwfoJBb6agnACgm9Fd
7VIk4aFNsHRGaf8+Stk6Qg0=
=rltP
-----END PGP SIGNATURE-----



More information about the thelist mailing list