Skip to content

Searching for a string parameter #2084

Answered by BurntSushi
aaisha79 asked this question in Q&A
Discussion options

You must be logged in to vote

Well, ripgrep is a line oriented search tool. So searching across lines requires enabling multi-line mode. To that end, the simple answer to your question is to write a regex that searches across multiple lines:

$ rg -U 'abc.*?\n.*?abcdef' /tmp/rg-2084.txt
1:                      <key>abc</key>
2:      <string>abcdef</string>

Your regex doesn't account for the fact that there are non-whitespace characters between abc and abcdef.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@aaisha79
Comment options

Answer selected by BurntSushi
Comment options

You must be logged in to vote
4 replies
@BurntSushi
Comment options

@aaisha79
Comment options

@BurntSushi
Comment options

@aaisha79
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants