StrTran()

Joe

Administrator
Staff member
Replace single quotes with nothing:
FoxPro:
STRTRAN(lcExample, "'", "")
C#:
Example = Example.Replace("'", "");
 
Last edited:

Joe

Administrator
Staff member
Case-insensitive example:
FoxPro:
lcExample = "Some text with 'RePlAcEtHiS' and more"
lcExample = Strtran(lcExample, "ReplaceThis", "WithThis", -1, -1, 1) && 1 means case-insensitive
MESSAGEBOX(lcExample)
C#:
String lcExample = "Some text with 'RePlAcEtHiS' and more";
Regex ThisRegex = new Regex("ReplaceThis", RegexOptions.IgnoreCase);
lcExample = ThisRegex.Replace(lcExample, "WithThis");
Console.WriteLine(lcExample);
Console.ReadKey();
Had problems with the Regex example when the string to replace with ("WithThis") started with a dollar sign as in "$0.00". It turns out the dollar sign in Regex means to append the new string to the end of the old. Solution is to turn the leading dollar sign into two.

 
Last edited:
Top