Hide closing braces

System.Text.RegularExpressions.Regex.Escape()disappears only when braces are opened. Is there a .NET Framework method that speeds up closing braces for use in regex? I can't seem to find. I would not like to hard code characters.

edit . I need to generate tags (? <-Open>) to determine group balancing. I get a list of characters representing the closing delimiters, avoid them, and then add them to the expression in the "(? <-Open>)" tags. So yes, I really need to avoid trailing brackets.

+5
source share
2 answers

, Escape (MSDN):

(\, *, +,?, |, {, [, (,), ^, $,., # ), escape-. , .

:

Escape ([) ({), (] }). . , . , . , , (). . "".

, }, {, .

+4

Regex.Escape . - ? , . , , , , .

FWIW, Regex.Escape() :

Regex.Escape("(Hello)"); // \(Hello\)
Regex.Escape("Hello)"); // Hello\)
Regex.Escape("(Hello"); // \(Hello

: , , , {, , . Regex.Escape() , , , , , . , : 1) , , 2) , -, Regex.Escape .

+1

All Articles