Regex.Unescape(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

參數

str
String

輸入字串,包含要轉換的文字。

傳回

字元字串,其中任何逸出字元轉換成其未逸出格式。

例外狀況

str 包含無法辨認的逸出序列。

strnull

備註

方法 Unescape 會執行下列兩個轉換之一:

  • 它會從 方法逸出的每個字元中移除逸出字元 (「\」) ,以反轉 方法所執行的 Escape 轉換。 其中包括 \、*、+、?、|、{、[、 (、) 、^、$、.、#和空白字元。 此外,方法會將 Unescape 右括弧 (]) 和右大括弧 (}) 字元。

注意

Unescape 無法完全反轉逸出的字串,因為它無法精確地推斷出哪些字元已逸出,

  • 它會以實際的可列印字元取代逐字字串常值中的十六進位值。 例如,它會以 「\a」 或 @"\x0A" 「\n」 取代 @"\x07" 。 它會轉換成支援的逸出字元,例如 \a、\b、\e、\n、\r、\f、\t、\v 和英數位元。

Unescape如果方法遇到無法轉換的其他逸出序列,例如 \w 或 \s,則會擲回 ArgumentException

適用於

另請參閱