简体   繁体   中英

How to use escape character in a verbatim string?

Can I use escape characters like \\r, \\n etc in verbatim string for example

string pattern = @"(?<!</institution>\r\n)(?<!<institution-wrap>\r\n)<institution type";

Now if I try to do a search or search and replace using the pattern will it work or will \\r\\n be treated as a normal string? How do I get around this?

In the pattern, yes, you can. See http://rextester.com/GHVMBZ97646 for an example. In a replacement, however, the backslash would be treated as a literal if you use a verbatim string, as in this question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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