C# 中的 Anchors函数

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

锚点允许匹配成功或失败,具体取决于字符串中的当前位置。下表列出了锚点−

Assertion Description Pattern Matches
^ The match must start at the beginning of the string or line. ^\d{3} "567" in "567-777-"
$ The match must occur at the end of the string or before\n at the end of the line or string. -\d{4}$ "-2012" in "8-12-2012"
\A The match must occur at the start of the string. \A\w{3} "Code" in "Code-007-"
\Z The match must occur at the end of the string or before\n at the end of the string. -\d{3}\Z "-007" in "Bond-901-007"
\z The match must occur at the end of the string. -\d{3}\z "-333" in "-901-333"
\G The match must occur at the point where the previous match ended. \\G\(\d\) "(1)", "(3)", "(5)" in "(1)(3)(5)[7](9)"
\b The match must occur on a boundary between a\w (alphanumeric) and a\W(nonalphanumeric) character. \w "R", "o", "m" and "1" in "Room#1"
\B The match must not occur on a\b boundary. \Bend\w*\b "ends", "ender" in "end sends endure lender"

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

技术教程推荐

硅谷产品实战36讲 -〔曲晓音〕

Nginx核心知识150讲 -〔陶辉〕

深入浅出计算机组成原理 -〔徐文浩〕

Serverless入门课 -〔蒲松洋(秦粤)〕

OAuth 2.0实战课 -〔王新栋〕

如何成为学习高手 -〔高冷冷〕

超级访谈:对话毕玄 -〔毕玄〕

B端产品经理入门课 -〔董小圣〕

后端工程师的高阶面经 -〔邓明〕

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