开发者

Replace All Function in VB.net

how can I re开发者_开发知识库place all string in string varaiable like

dim str = "I am testing and testing and testing"

After replace with "and"

ReplaceAll(str,"and","or")

How can I replace all with case insentive not case sensative?


Sounds like a case for regular expressions:

From http://weblogs.asp.net/jgalloway/archive/2004/02/11/71188.aspx

using System.Text.RegularExpressions;

string myString = "find Me and replace ME";
string strReplace = "me";

myString = Regex.Replace(myString, "me", strReplace, RegexOptions.IgnoreCase);


    Dim str As String = "I am testing and testing and testing"
    str = str.Replace("and", "or")


Despite the use of Regular Expression, as suggested by Matt and RQDQ, you can use the VB sugar, like:

Replace(expression, find, replacement, start, count, compare)

From the documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜