使用 pcre:yes 启用多行搜索
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您还可以通过在搜索中添加 pcre:yes
,使用 RE2 支持的 PCRE 子集进行搜索。使用 pcre:yes
时,整个搜索表达式会被视为与 Perl 兼容的正则表达式。
如果您想跨换行符进行搜索,此功能会特别有用。
搜索 {\s+generate_java pcre:yes
找到
mojom("mojom") {
generate_java = true
而搜索 {\s+generate_java
则不会,因为 {
与 generate_java
不在同一行。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eSearching with \u003ccode\u003epcre:yes\u003c/code\u003e enables the use of Perl-compatible regular expressions (PCRE) supported by RE2, allowing for more complex search patterns.\u003c/p\u003e\n"],["\u003cp\u003ePCRE searches are particularly useful for finding patterns across line breaks, which standard searches may not capture.\u003c/p\u003e\n"],["\u003cp\u003eFor example, using \u003ccode\u003epcre:yes\u003c/code\u003e enables searches like \u003ccode\u003e{\\s+generate_java\u003c/code\u003e to find instances where the opening bracket and \u003ccode\u003egenerate_java\u003c/code\u003e are on separate lines.\u003c/p\u003e\n"]]],[],null,["# Enabling multiline search with pcre:yes\n\nYou can also search using the\n[PCRE subset supported by RE2](http://htmlpreview.github.io/?https://github.com/google/re2/blob/master/doc/syntax.html)\nby adding `pcre:yes` to your search. When you use `pcre:yes`, the entire\nsearch expression is treated as a perl-compatible regular expression.\n\nThis is particularly useful when you want to do a search across line breaks.\n\nA search for `{\\s+generate_java pcre:yes` finds \n\n mojom(\"mojom\") {\n generate_java = true\n\nwhile the search `{\\s+generate_java` will not because `{` is not on the same line as `generate_java`."]]