A single line sed command can remove quotes from start and end of the string. The above sed command execute two expressions against the variable value. The first expression 's/^"//' will remove the starting quote from the string. Second expression 's/"$//' will remove the ending quote from the string.
2.2.3 Double-Quotes In Sed's specification, s command: The meaning of an unescaped backslash immediately followed by any character other than '&', backslash, a digit, newline, or the delimiter character used for this command, is unspecified.
To remove double quotes just from the beginning and end of the String, we can use a more specific regular expression: String result = input. replaceAll("^\"|\"$", ""); After executing this example, occurrences of double quotes at the beginning or at end of the String will be replaced by empty strings.
A single quote is not used where there is already a quoted string. So you can overcome this issue by using a backslash following the single quote. Here the backslash and a quote are used in the “don't” word. The whole string is accompanied by the '$' sign at the start of the declaration of the variable.
Why use sed?
| tr -d '"'
Right tool for the right job.
You can do:
...existing_commands | sed 's/"//g'
A little late to the party, this this utility sounds like it can be useful for parsing the json twitter returns: http://stedolan.github.io/jq/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With