[PLUG] emacs: regex replace modified search string
Galen Seitz
galens at seitzassoc.com
Fri Jun 26 18:39:48 UTC 2015
On 06/26/15 10:20, Rich Shepard wrote:
> On Fri, 26 Jun 2015, Galen Seitz wrote:
>
>> If you don't give us the complete problem, you're unlikely to get a
>> complete answer. Anyway, wrapping the strings you want to keep in parens
>> is key.
>
> galen,
>
> OK. Here's an example row:
> 'B',1992-03,Cl,4
> and what I want is to convert it to:
> 'B','1992-03','Cl',4
>
> The regex I tried to quote the year portion of the date:
> ,\([:digit:]\{4\}-[:digit:]\{2\}\) RET ,'\1
> did nothing. The plan was to do one chunk at a time because my regex skill
> is not sufficient to do it all in one step.
To quote whatever is in the N+1 CSV column:
search: ^\(\([^,]*,\)\{N\}\)\([^,]*\)\(,.*\)
replace: \1'\3'\4
This won't work if you are trying to quote the first or last column, as
it expects ',' surrounding the thing you are quoting.
galen
--
Galen Seitz
galens at seitzassoc.com
More information about the PLUG
mailing list