Issue
I'm trying to clean words :
{"id":1, "name":Robert}, {"id":2, "name":"Skylar"}, {"id":3, "name":"Ben"}, {"id":4, "name":Anne}
become have double quotation for all words after "name":
like below:
{"id":1, "name":"Robert"}, {"id":2, "name":"Skylar"}, {"id":3, "name":"Ben"}, {"id":4, "name":"Anne"}
How do I clean this using sed?
Thanks
Solution
sed 's/\("name":\)\([A-Za-z]\+\)/\1"\2"/g' file
\("name":\)
(ERE:("name":)
) matches"name":
and places it in capture group 1,\([A-Za-z]\+\)
(ERE:([A-Za-z]+)
) matches a group of chars comprising letters A to Z and a to z and places it in capture group 2,\1
and\2
expand to contents of capture groups.
Answered By - oguz ismail