替换VB.net中的所有函数

时间:2011-04-18 19:58:12

标签: vb.net replace

如何替换

中的字符串变量中的所有字符串
dim str = "I am testing and testing and testing"

用“和”替换后

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

如何用不区分大小写的方式替换所有不敏感的内容?

3 个答案:

答案 0 :(得分:4)

听起来像正则表达式的情况:

来自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);

答案 1 :(得分:1)

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

答案 2 :(得分:1)

尽管使用正则表达式,如Matt和RQDQ所建议的,你可以使用VB糖,如:

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

来自documentation

相关问题