知识卡片
原始字符串的匹配定界
正则表达式或 Windows 路径含很多反斜杠时,可写 r"C:\Program Files\Gorillas" 一类原始字符串,内部字符按其原样保存。若内容也包含双引号,可用 r#"..."#,结束必须连续遇到双引号和匹配数目的井号。内容恰好包含这种组合时,增加两端的井号数。
关联阅读:[[普通字面量的转义和续行]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Fundamental Types 字面量中的转义、多行与原样文本 · 查看原书依据
raw string is tagged with the lowercase letter r. All backslashes and whitespace characters inside a raw string are included verbatim in the
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第02章《Fundamental Types》|字面量中的转义、多行与原样文本,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch02.xhtml#string-and-character-literals`
- 结论依据:原文先说明原始字符串不识别转义,再展示三井号扩展能把双引号留在文本里。
- 原始内容:raw string is tagged with the lowercase letter r. All backslashes and whitespace characters inside a raw string are included verbatim in the