寻找“$ {sometext}”的正则表达式
问题描述:
我发现使用这个 "\\${(.*?)\\}
。
所以,我想: new Regex(@"\\$\\${(.*?)\\}");
但这似乎并不在这里工作,什么问题呢?
答
我会用new Regex(@"\${(.*?)}");
我们来分析一下你:
(@"\\$\\${(.*?)\\}");
^^^^^^ ^^^
|||||| |||-- Your don't need to double your slashes in a literal string.
\ | |
\ | |
\|--------|-- You have 2 "$" and you just want one
|
|-- You don't need to escape "{" since it doesn't enclose digits
and can't be interpreted as a length attribute.
这有什么错[string.Contains(https://msdn.microsoft.com/en-us/library/dy85x1sa(V = vs.110)的.aspx)? – Liam
你有一个罕见的问题:**只有一个*美元*太多... **第二个'''不需要...尝试'新的正则表达式(@“\\ $ \\ {(。*?) \\}});' – ppeterka
特别阅读[这个答案](http://*.com/a/5848360/542251) – Liam