简体   繁体   English

Visual Studio 正则表达式查找和替换功能

[英]Visual Studio Regex Find and Replace function

I'm trying to find all var.AppendLine("...");我试图找到所有var.AppendLine("..."); and replace them with Append("...\\n");并将它们替换为Append("...\\n");

Been fooling around with regex's but don't seem to get anywhere.一直在玩正则表达式,但似乎一无所获。 Anyone has a suggestion on what regular expression to use here?有人对在这里使用什么正则表达式有任何建议吗?

var can be a variable name and I need to select the ... for replace with Append("$1\\n"); var可以是变量名,我需要选择...替换为Append("$1\\n");

I think you meand the regex in the "search& replace window of VS ? Then something like我想你的意思是“VS 的搜索和替换窗口中的正则表达式?然后像

<{[a-zA_Z]+\.}{AppendLine\("}{[^"]+}{"\)}

to replace with替换为

\1Append("\3\\n")

(remove the \\1 if you want to remove the "var." part, not clear in your question) (如果您想删除“var.”部分,请删除 \\1,在您的问题中不清楚)

I assume you actually don't want to get rid of var :我假设您实际上不想摆脱var

Search: <{[a-zA-Z0-9]+}.AppendLine\\("{[^"]+}"\\)搜索: <{[a-zA-Z0-9]+}.AppendLine\\("{[^"]+}"\\)

Replace with: \\1.Append("\\2\\\\n")替换为: \\1.Append("\\2\\\\n")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM