TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:9061] regex



try:
g:[^ ][^ ]*:s::'&':g

or
s/[^ ][^ ]*/'&'/g

Which says search for one non-blank character followed by any
more and then replace the while thing with the quoted one.

hope this helps.
--

On Sat, 9 Oct 1999, Luke Francl wrote:

> Hey all,
> 
> Does anybody know a regular expression (in vi, preferably) I can use to
> take an arbitary number of strings of 2-4 characters and replace them with
> the same string, surrounded with single quotes and a comma afterwards.
> (Basically, I want to take a file full of acronyms and create a
> comma-delimited list with tick marks around every acronym).
> 
> For example,
> 
> FOO would become 'FOO', 
> FBAR would become 'FBAR',
> 
> I've tried a bunch of stuff, but nothing I have tired works. It either
> does the whole line as one string, like
> 
> s/.*/\'&\',/g 
> 
> or breaks up strings like,
> 
> s/..../\'&\',/g
> 
> The one above is so close I can taste it, but I can't figure it
> out....Anybody?
> 
> Luke
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org
> 
>