0

I am trying to edit a text file using vi where I want to replace the matches of [a-z],[A-Z] with:

{matching value of [a-z]}{a space instead of a comma}{matching value of [A-Z]}.

For example: Bourbon,Glazed,Turkey,

would be replaced with: Bourbon Glazed Turkey,

I was thinking it might be using grouping & back referencing? But I have not figured that out yet.

1
  • I just figured it out. Came back to answer my own question, but you two beat me to te same answer I came up with! Thanks for your time!
    – DragRacerX
    Nov 24 '15 at 19:05
1

The vi command %s/\([a-z]\),\([A-Z]\)/\1 \2/g will change

y,S
T,d
5,e

into

y S
T,d
5,e
0
$ echo 'Bourbon,Glazed,Turkey,' | sed 's/\([a-z]\),\([A-Z]\)/\1 \2/g'
Bourbon Glazed Turkey,
$

So in vi it's the same:

:%s/\([a-z]\),\([A-Z]\)/\1 \2/g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.