如何替换string varaiable中的所有字符串,如
dim str = "I am testing and testing and testing"替换为"and“
ReplaceAll(str,"and","or")我怎样才能用大小写敏感而不是大小写敏感来替换所有的?
发布于 2011-04-19 04:01:10
听起来像是正则表达式的情况:
来自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);发布于 2011-04-19 04:03:00
Dim str As String = "I am testing and testing and testing"
str = str.Replace("and", "or")发布于 2011-04-19 04:03:36
尽管使用了正则表达式,正如Matt和RQDQ所建议的那样,您可以使用VB糖,例如:
Replace(expression, find, replacement, start, count, compare)来自documentation的。
https://stackoverflow.com/questions/5708171
复制相似问题