Question

I have a query that needs to be read from app.config file. 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".

I am getting an error that says "Invalid Character in a Decimal Number [."

Was it helpful?

Solution

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;, &#35; and &#91;.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top