简体   繁体   English

如何转义[在app.config文件中?

[英]How to escape [ in app.config file?

I have a query that needs to be read from app.config file. 我有一个需要从app.config文件读取的查询。 The query contains a regular expression. 该查询包含一个正则表达式。 I am not able to specify character class within the regular expression value. 我无法在正则表达式值中指定字符类。 The compiler does not recognize the character [. 编译器无法识别字符[。 How do I escape it? 我该如何逃脱?

Here is my config file value 这是我的配置文件值

<add key="GetIds" value="select top 1000 Id from Table1 where  dbo.RegexMatch(TEXT, '&#[0-9]+;|&amp;', 0) > 0 "/>

where dbo.RegexMatch is a stored procedure that finds the given pattern in "TEXT". 其中dbo.RegexMatch是一个存储过程,可以在“ TEXT”中找到给定的模式。

I am getting an error that says "Invalid Character in a Decimal Number [." 我收到一条错误消息,指出“小数数字中的无效字符[。”

Use that 用那个

<add key="GetIds" value="select top 1000 Id from Table1 where  dbo.RegexMatch(TEXT, '&amp;&#35;&#91;0-9]+;|&amp;amp;', 0) > 0 "/>

You should replace & , # and [ with their respecive HTML codes : &amp; 您应将&#[替换为其相应的HTML代码&amp; , &#35; &#35; and &#91; &#91; .

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

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