Enabling multiline search with pcre:yes
Stay organized with collections
Save and categorize content based on your preferences.
You can also search using the
PCRE subset supported by RE2
by adding pcre:yes
to your search. When you use pcre:yes
, the entire
search expression is treated as a perl-compatible regular expression.
This is particularly useful when you want to do a search across line breaks.
A search for {\s+generate_java pcre:yes
finds
mojom("mojom") {
generate_java = true
while the search {\s+generate_java
will not because {
is not on the same line as generate_java
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-03 UTC.
[null,null,["Last updated 2023-10-03 UTC."],[[["\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`."]]