How can I swap some values in a string variable and write it back with new values using Free Pascal?
Having read a line from a text file using ReadLn(InputFile, strVar), I need to read each character of strVar, and if it contains the letter 'E' (for example), I want to output (write to a new file, in fact) the original variable but with the 'E' being swapped\replaced with the numeric digit '3'.
So, if '开发者_如何学PythonExample' is read from the file, I want '3xample' to be written to a new file.
How do I code the swapping in Free Pascal (I can do the writing to the file bit)? Other languages seem to have a swap function or something.
Thanks
Ted
You can use StringReplace
strVar := StringReplace(strVar, 'E', '3', [rfReplaceAll]);
精彩评论