Breyta

Deila með


Regex.Unescape(String) Method

Definition

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

Parameters

str
String

The input string containing the text to convert.

Returns

A string of characters with any escaped characters converted to their unescaped form.

Exceptions

str includes an unrecognized escape sequence.

str is null.

Remarks

The Unescape method performs one of the following two transformations:

  • It reverses the transformation performed by the Escape method by removing the escape character ("\") from each character escaped by the method. These include the \, *, +, ?, |, {, [, (,), ^, $, ., #, and white space characters. In addition, the Unescape method unescapes the closing bracket (]) and closing brace (}) characters.

Note

Unescape cannot reverse an escaped string perfectly because it cannot deduce precisely which characters were escaped,

  • It replaces the hexadecimal values in verbatim string literals with the actual printable characters. For example, it replaces @"\x07" with "\a", or @"\x0A" with "\n". It converts to supported escape characters such as \a, \b, \e, \n, \r, \f, \t, \v, and alphanumeric characters.

If the Unescape method encounters other escape sequences that it cannot convert, such as \w or \s, it throws an ArgumentException.

Applies to

See also