Closed feng-qi closed 2 years ago
Besides, one can use the dot all
modifier, which looks like (?s)
, to change the dot's behavior if --multiline-dotall
is not available. https://til.hashrocket.com/posts/9zneks2cbv-multiline-matches-with-ripgrep-rg
Using option
--multiline
doesn't necessarily mean the user also wants--multiline-dotall
. The user may be certain about the number of new lines involved. For example, with this code snippet:If I want to search all the #ifdef followed by a
else
statement, I can use regex#ifdef.*\n.*else
. If--multiline-dotall
is used, this regex will match more lines than I expected.