我有一个字符串,我正在使用 RegEx 将字符串替换为特定模式。基本上我想修剪命名组中的空白
例如:
myString1: substringof('test',Name)
myString2: substringof(' test ',Name)
myString3: substringof('test ',Name)
Expected output: Name.Contains(\"test\")
myString4: substringof(' test test ',Name)
myString5: substringof(' test test',Name)
myString6: substringof('test test ',Name)
Expected output: Name.Contains(\"test test\")
代码:
var replaceRegex = new Regex(substringof\\(\\s*'(?<text>[^']+'?[^']*)'\\s*,\\s*(?<pname>[\\w\\[\\]]+)\\s*\\)");
myString = replaceRegex.Replace(myString, "${pname}.Contains(\"${text}\")");
任何帮助将不胜感激。提前致谢!!