我怎麼能代替所有的字符串中的字符串varaiable像全部替換功能在VB.net
dim str = "I am testing and testing and testing"
更換後「和」
ReplaceAll(str,"and","or")
如何與案件insentive不區分全部更換sensative?
我怎麼能代替所有的字符串中的字符串varaiable像全部替換功能在VB.net
dim str = "I am testing and testing and testing"
更換後「和」
ReplaceAll(str,"and","or")
如何與案件insentive不區分全部更換sensative?
聽起來像是正則表達式的情況下:
從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")
這是一個案例_sensitive_替換。 – RQDQ 2011-04-18 20:04:30
儘管使用正則表達式的,由馬特和RQDQ的建議,你可以使用VB糖,像:
Replace(expression, find, replacement, start, count, compare)
對不起,我不是一個VB/VBScript/.NET的傢伙,睡眠剝奪啓動。 – 2011-04-18 20:03:37
@Matt Ball - 不用擔心! – RQDQ 2011-04-18 20:06:45
Regex.Replace(「123456」,「。」,「」,RegexOptions.IgnoreCase)這會返回空字符串爲什麼? – 2011-04-18 20:21:02