Reading regular expressions and strings from app.config

I am trying to read regex from app.config file

if I try to read lines, it works fine, but if I try to get a regex pattern, it will not accept my pattern

Here is my code

<appSettings>
<add key="regex" value=@"^(?<TicketNum>\w{3}-\d+)\s+(?<Message>.+?)$"></add>
<add key="getString" value="siva"/>;
</appSettings>

Did I miss something?

+4
source share
1 answer

You have to run <and >in a xml, try the following:

<appSettings>
    <add key="regex" value="^(?&lt;TicketNum&gt;\w{3}-\d+)\s+(?&lt;Message&gt;.+?)$"/>
</appSettings>

Removing XML data . Here:

enter image description here

There is also no need for a sign @.

+6
source

Source: https://habr.com/ru/post/1673101/


All Articles