如何替换
中的字符串变量中的所有字符串dim str = "I am testing and testing and testing"
用“和”替换后
ReplaceAll(str,"and","or")
如何用不区分大小写的方式替换所有不敏感的内容?
答案 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)