我正在尝试查找带有被包围的空格的单词(
,)
或者,
将其用引号引起来。
例如,在此表达式中,-Development life cycle
和enterprise service bus
将用引号引起来。
编辑-仅包装短语,即在单词之间包含空格的单词
(AND(OR(SDLC,development life cycle),design,requirements,OR(biztalk,Websphere,TIBCO,Webmethods,ESB,enterprise service bus)))
(?<=[(,])([^(),]* [^(),]*)(?=[),])
试试这个。参见DEMO。
替换为"$1"
或"\1"
string strRegex = @"(?<=[(,])([^(),]* [^(),]*)(?=[),])";
Regex myRegex = new Regex(strRegex, RegexOptions.Multiline);
string strTargetString = @"(AND(OR(SDLC,development life cycle),design,requirements,OR(biztalk,Websphere,TIBCO,Webmethods,ESB,enterprise service bus)))" + "\n" + @" AND(OR(SDLC,""development life cycle""),OR(banking,AML,anti-money laundering,KYC,know your customer),OR(technology strategy,technical strategy,technical architecture,technology architecture,architect*)";
string strReplace = @"""$1""";
return myRegex.Replace(strTargetString, strReplace);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句