Giter Club home page Giter Club logo

Comments (3)

BurntSushi avatar BurntSushi commented on June 5, 2024

Shell pipelines are your best bet. e.g., rg -U 'red stage,\p{any}*foo' | rg 'red|foo'.

Otherwise, your task seems pretty specialized. If you need to do one or two ad hoc queries, then ripgrep is probably a good fit. But if you need something more systematic and flexible, I'd probably build a bespoke tool for it personally.

from ripgrep.

quidnu avatar quidnu commented on June 5, 2024

Actually I misunderstood what multiline does, I want to match phrases across line breaks something like "red\s\stage\sfoo" but that's easy to do and okay (if you put aside the interleaved metadata problem). I think your example doesn't work because it would match 'red stage, blue stage, foo'.

I think what I'll end up doing is pre-processing the file, removing the metadata, extracting the matching line numbers from rg and printing those lines in the original file using sed/awk.

(I understand that it's probably too far afield of what rg is intended to do, but what I was originally thinking was that you would be able to, in the most general case, do something like rg --extractor-fn "jq '.text'" to be able to search only the text across lines (and still output the entire data structure) of something like {'ts': 111, 'text': 'this text continues on'} {'ts':112, 'text': ' the next line'}. Or for simpler cases that can be handled with regex: rg --mask "-- \d\d:\d\d$")

Anyway thanks and feel free to close.

from ripgrep.

BurntSushi avatar BurntSushi commented on June 5, 2024

Yeah ripgrep isn't arbitrarily flexible like that. With that said, it does have the --pre flag, which lets you run any program to transform the input in whatever way you want before ripgrep will search it. The docs give an example of how to use ripgrep to transparently search the plain text of PDF files.

from ripgrep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.