Regex.Unescape(String) Método
Definição
Converte qualquer caractere de escape na cadeia de caracteres de entrada.Converts any escaped characters in the input string.
public:
static System::String ^ Unescape(System::String ^ str);
public static string Unescape (string str);
static member Unescape : string -> string
Public Shared Function Unescape (str As String) As String
Parâmetros
- str
- String
A cadeia de caracteres de entrada que contém o texto a ser convertido.The input string containing the text to convert.
Retornos
Uma cadeia de caracteres com qualquer caractere de escape convertido em sua forma sem escape.A string of characters with any escaped characters converted to their unescaped form.
Exceções
str inclui uma sequência de escape não reconhecida.str includes an unrecognized escape sequence.
str é null.str is null.
Comentários
O Unescape método executa uma das duas transformações a seguir:The Unescape method performs one of the following two transformations:
- Ele reverte a transformação executada pelo Escape método removendo o caractere de escape (" \ ") de cada caractere de escape pelo método.It reverses the transformation performed by the Escape method by removing the escape character ("\") from each character escaped by the method. Isso inclui os \ caracteres, *, +,?, |, {, [, (,), ^, $,., # e espaços em branco.These include the \, *, +, ?, |, {, [, (,), ^, $, ., #, and white space characters. Além disso, o Unescape método não escapa o colchete de fechamento (]) e os caracteres de fechamento (}).In addition, the Unescape method unescapes the closing bracket (]) and closing brace (}) characters.
Observação
Unescape Não é possível reverter uma cadeia de caracteres de escape perfeitamente porque ela não pode deduzir precisamente quais caracteres foram ignorados,Unescape cannot reverse an escaped string perfectly because it cannot deduce precisely which characters were escaped,
- Ele substitui os valores hexadecimais em literais de cadeia de caracteres textuais pelos caracteres imprimíveis reais.It replaces the hexadecimal values in verbatim string literals with the actual printable characters. Por exemplo, ele substitui @"\x07" por "\a" ou @"\x0A" por "\n".For example, it replaces @"\x07" with "\a", or @"\x0A" with "\n". Ele converte para caracteres de escape com suporte, como \a, \b, \e, \n, \r, \f, \t, \v e caracteres alfanuméricos.It converts to supported escape characters such as \a, \b, \e, \n, \r, \f, \t, \v, and alphanumeric characters.
Se o Unescape método encontrar outras sequências de escape que ele não possa converter, como \w ou \s, ele lançará um ArgumentException .If the Unescape method encounters other escape sequences that it cannot convert, such as \w or \s, it throws an ArgumentException.