I am trying to replace strings in a document that enclosed in single quotes, to a string without.
'test' -> test
Is there a way using sed I can do this?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will remove single quotes from around any quoted word, and leave other quotes alone:
When tested:
Notice that it left the quote in
it'sintact.Explanation:
The search regex
'([a-zA-Z]*)'is matching any word (letters, no spaces) surrounded by quotes and using brackets, it captures the word within. The replacement regex\1refers to “group 1” – the first captured group (ie the bracketed group in the search pattern – the word)FYI, here’s the test: