0
此代碼不起作用,但它適用於其他表達式,如(?:[A-Za-z][A-Za-z0-9_]*)
。用正則表達式替換C#
以下表達式工作在正則表達式測試儀correctley,但它並沒有在此代碼ID替換您好:
string test = "int Hello := 2 ;";
string pattern = "\b(?!int|bool)(?:[A-Za-z][A-Za-z0-9_]*)\b";
string replacement = "Id";
Regex rgx = new Regex(pattern);
string newline = rgx.Replace(test, replacement);