Written by

Question Leon Duveen · Apr 11, 2022

I need to remove double quotes (") from a string

I need to remove double quotes (") from a string and can't remember how to escape it in input string in ReplaceStr or Strip.  

Thanks in advance

Comments

David Underhill  Apr 11, 2022 to Sergei Shutov

That removes all " characters, while these are indeed doublequote's, someone could also mean "" where there are double quotes, as in quotes inside a quoted string (str="this is a quote"".")

For that

$translate(str,"""""","""")

or I find it more readable to use the ASCII value so to remove

$translate(str,$c(34.34),"")

or to replace with a single "

$replace(str,$c(34,34),$c(34))
0
Julius Kavay  Apr 11, 2022 to David Underhill

Sergei Shutov's answer is correct. The question was, how to remove a specific character (in this case: double quotes) from a string. Your answer is also correct but he told nothing about quoted strings.

The problem is, we have a question but no explanatory examples. Something like xxxx is the string I have, and
 yyyyy  is the string, I want to get.

0
Sergei Shutov  Apr 11, 2022 to Julius Kavay

David's answer is not quite correct because one can't use $translate to search for groups of symbols (like two quotes next to each other), this is what $replace function is for. $translate always search for an individual character.

0
Julius Kavay  Apr 12, 2022 to Sergei Shutov

I referred in his answer only the $replace() function without explicit pointing this out. I was upset about the ambiguous question, sorry.

0
Vitaliy Serdtsev · Apr 12, 2022

Choose according to your taste:

<FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">%systemInclude

</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34,34)</FONT><FONT COLOR="#008000">"te""""st"</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34,34)    </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">,!,   </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Global</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">UndoubleInnerQuotes</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">),!,   </FONT><FONT COLOR="#0000ff">$$$StripQuotes</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">),!,   </FONT><FONT COLOR="#0000ff">$tr</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34),</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">)</FONT>

Output: USER>d ^test ""te""st"" "te"st" "te"st" test

0
Steven Hobbs · Apr 19, 2022

Leon has not made a return comment and his original question would be ambiguous to some people.  I often call the " character, the 'double quote' character while I often call the ' character the 'single quote' character.  Other names I might use for the " character are 'quotation character' or 'ditto mark'.  Other names for the ' character would be 'apostrophe' or 'apostrophe quotation character'.  [[Notice I am using apostrophe quotation characters in this comment.]]  I might describe "" characters as 'doubled quotation characters' or 'doubled double quotes'.

Since Leon asked to 'remove double quotes (") from a string' my first impression would be to remove all " characters from the string.  I.e., every $C(32) should be removed.  If Leon wanted to only remove 'doubled quotation characters' then he probably would have written 'remove double quotes ("") from a string'.

0