Skip to content

StripQuotes ​

This StripQuotes function removes surrounding quote characters from aValue.

The quote character to remove is specified by aChar.

If the string aValue does not have quotes, then nothing happens and aValue is returned without change.

If the string aValue contains the aChar character escaped, then any escaping will be removed.

INFO

Escaping simply means that a text character within a string is preceded by another symbol that indicates that the character following the escape symbol should interpreted literally and should be treated as text only, and is not a control character.

Declaration: Function StripQuotes( const aValue : string; aChar : Char) : string;

Example

pascal
procedure OnMapEvent(var Value:Variant);
var
  Str1, Str2, Str3, Str4, Str5 : string;
begin
 //Returns    Pirates
  Str1 := StripQuotes('"Pirates"','"');

 //Returns    O'Sullivan
  Str2 := StripQuotes('"O''Sullivan"','"');

 //returns    ab"c
  Str3 := StripQuotes('"ab""c"', '"');

 //Returns    Churchill said "If you're going through hell, keep going."
  Str4 := StripQuotes('"Churchill said "If you''re going through hell, keep going.""', '"');

 //What went in, came back out - with no change made
 //Returns     He devised a new way to cut cakes.
  Str5 := StripQuotes('He devised a new way to cut cakes.', '"');

end;