简体   繁体   English

好的和简单的RegEx我无法解决

[英]Nice and Simple RegEx I can't work out

I'm trying to build a QueryString Reader from my app.config in the most part I have it working now I'm trying to add other config properties into the value EG 我正在尝试从我的app.config中构建一个QueryString Reader,现在我可以正常工作了,我正在尝试将其他配置属性添加到值EG中。

<add key="Database[TableNames[Tracks]]" value="tracks" />
<!-- others... -->
<add key="Database[Querys[selectTracks]]" value="SELECT * FROM `{@Database[TableNames[Tracks]]}` WHERE track_id = '{0}'">

From the above I have the Key Database[TableNames[Tracks]] set and now I'm trying to use it in the value of Database[Querys[selectTracks]] but I can't figure out the RegEx I need to use to match it it cant be on all {.*} or {[A-Za-z0-9]} as this will match the String.Format {0} property and I don't want that it has to capture on the the \\{@.[a-zA-Z0-9!\\}]\\} but that is not correct could some one give me the correct way to match my pattern? 从上面我已经设置了关键Database[TableNames[Tracks]] ,现在我试图在Database[Querys[selectTracks]]的值中使用它,但是我无法弄清楚我需要用来匹配的RegEx它不能在所有{.*}{[A-Za-z0-9]}因为它将与String.Format {0}属性匹配,并且我不希望它必须在\\{@.[a-zA-Z0-9!\\}]\\}但这是不正确的,有人可以给我正确的方式来匹配我的模式吗?

I'm using http://www.regextester.com/ to test the RegEx Matches 我正在使用http://www.regextester.com/测试RegEx匹配项

I'm a bit confused about what you are asking for here. 我对您在这里的要求感到困惑。 if it's just a way to match the value within the backticks, will this do the trick for you? 如果这只是在反引号中匹配值的一种方式,那么这是否对您有用?

\{@[a-zA-Z0-9\[\]]+\}

This matches the literal "{@" followed by 1 or more of the following characters "a-zA-Z0-9[]" and endind with the literal "}" 这与文字“ {@”匹配,后跟一个或多个以下字符“ a-zA-Z0-9 []”,并以文字“}”结尾

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

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