Henry Olive 5 Posted November 12 Good Day Str := 'Abc' or could be Abc First, I want check if first char = ' then i want to delete it Second I want check if Last char = ' then i also want to delete it that is, if Str='Abc' then the result should be Abc if Str = Abc then i dont need to do anything Thank You Share this post Link to post
JonRobertson 72 Posted November 12 There is a lot of information and documentation available about string handling in Delphi. Here are two quick references: http://www.delphibasics.co.uk/ByFunction.php?Main=Strings https://www.thoughtco.com/string-handling-routines-delphi-programming-4092534 And here is a very basic solution to your request. Your actual purpose may be different from your description, but this code does what you asked: var str := '''abc'''; WriteLn(str); if str[1] = '''' then Delete(str, 1, 1); var last := Length(str); if str[last] = '''' then Delete(str, last, 1); WriteLn(str); ReadLn; Share this post Link to post
Remy Lebeau 1392 Posted November 12 42 minutes ago, Henry Olive said: First, I want check if first char = ' then i want to delete it Second I want check if Last char = ' then i also want to delete it The SysUtils unit in Delphi's RTL has AnsiDequotedStr() and AnsiExtractQuotedStr() functions for that exact purpose. 2 Share this post Link to post