我想用同一個單詞的大寫版本替換任何特定單詞的出現。VB.NET - Regex.Replace首字母大寫的句子
代碼:
Dim Sentence As String = "select * from table where field = 1"
Dim Words As New List(Of String)({"SELECT", "FROM", "UPDATE", "WHERE"})
For Each w As String In Words
Sentence = Regex.Replace(Sentence, "??", w, RegexOptions.IgnoreCase)
loop
你也許能看到我這個去...
Here is reference for Regex.Replace
,但我無法弄清楚。
編輯:我只希望替換開始/「字」用空格或斷行或開始/文件的末尾結束。所以像這樣:^m?(word)$m?
?
因此,只有存儲在一個列表中選擇特定詞? – 2015-02-12 06:18:55
是的,這是正確的。 – CrazyTim 2015-02-17 01:39:01