我发现了这个
"\\${(.*?)\\}
。
所以我试过了:
new Regex(@"\\$\\${(.*?)\\}");
但这似乎不起作用,这里的问题是什么?
答案 0 :(得分:3)
我会使用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.