Is there a case insensitive string replace in .Net without using Regex?

前端 未结 9 1628
天涯浪人
天涯浪人 2020-12-11 00:45

I recently had to perform some string replacements in .net and found myself developing a regular expression replacement function for this purpose. After getting it to work I

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 01:27

    You can use Microsoft.VisualBasic.Strings.Replace and pass in Microsoft.VisualBasic.CompareMethod.Text to do a case insensitive replace like this:

    Dim myString As String = "One Two Three"
    myString = Replace(myString, "two", "TWO", Compare:= CompareMethod.Text)
    

提交回复
热议问题