C# 中的 Character escapes函数

首页 / C#入门教程 / C# 中的 Character escapes函数

These are basically the special characters or escape characters. The backslash character (\) in a regular expression indicates that the character that follows it either is a special character or should be interpreted literally.

下表列出了转义字符−

无涯教程网

链接:https://www.learnfk.comhttps://www.learnfk.com/csharp/csharp-character-escapes.html

来源:LearnFk无涯教程网

Escape character Description Pattern Matches
\a Matches a bell character,\u0007. \a "\u0007" in "Warning!" + '\u0007'
\b In a character class, matches a backspace,\u0008. [\b]{3,} "\b\b\b\b" in "\b\b\b\b"
\t Matches a tab,\u0009. (\w+)\t "Name\t", "Addr\t" in "Name\tAddr\t"
\r Matches a carriage return,\u000D. (\r is not equivalent to the newline character,\n.) \r\n(\w+) "\r\nHello" in "\r\Hello\nWorld."
\v Matches a vertical tab,\u000B. [\v]{2,} "\v\v\v" in "\v\v\v"
\f Matches a form feed,\u000C. [\f]{2,} "\f\f\f" in "\f\f\f"
\n Matches a new line,\u000A. \r\n(\w+) "\r\nHello" in "\r\Hello\nWorld."
\e Matches an escape,\u001B. \e "\x001B" in "\x001B"
\nnn Uses octal representation to specify a character (nnn consists of up to three digits). \w\040\w "a b", "c d" in "a bc d"
\x nn Uses hexadecimal representation to specify a character (nn consists of exactly two digits). \w\x20\w "a b", "c d" in "a bc d"
\c X\c x Matches the ASCII control character that is specified by X or x, where X or x is the letter of the control character. \cC "\x0003" in "\x0003" (Ctrl-C)
\u nnnn Matches a Unicode character by using hexadecimal representation (exactly four digits, as represented by nnnn). \w\u0020\w "a b", "c d" in "a bc d"
\ When followed by a character that is not recognized as an escaped character, matches that character. \d+[\+-x\*]\d+\d+[\+-x\*\d+ "2+2" and "3*9" in "(2+2) * 3*9"

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

Go语言核心36讲 -〔郝林〕

从0开始学大数据 -〔李智慧〕

消息队列高手课 -〔李玥〕

雷蓓蓓的项目管理实战课 -〔雷蓓蓓〕

分布式系统案例课 -〔杨波〕

Python自动化办公实战课 -〔尹会生〕

人人都用得上的数字化思维课 -〔付晓岩〕

Vue 3 企业级项目实战课 -〔杨文坚〕

快速上手C++数据结构与算法 -〔王健伟〕

好记忆不如烂笔头。留下您的足迹吧 :)