Ripgrep: Globs vs regex?

Created on 23 Feb 2018  路  2Comments  路  Source: BurntSushi/ripgrep

What version of ripgrep are you using?

ripgrep 0.6.0
-AVX -SIMD

What operating system are you using ripgrep on?

System Version: macOS 10.13.3 (17D47) Kernel Version: Darwin 17.4.0 Boot Volume: Macintosh HD

Describe your question, feature request, or bug.

I'm just not really grasping the difference between

rg -g '*something*' 'def some_method_somewhere'

and

rg -g '.*something.*' 'def some_method_somewhere'

Should I assume globs work like Unix and * are wildcards?

Also, do double quotes behave the same way?

question

Most helpful comment

Should I assume globs work like Unix and * are wildcards?

Yes. As documented:

-g, --glob <GLOB>...                    
       Include or exclude files and directories for searching that match the given
       glob. This always overrides any other ignore logic. Multiple glob flags may be
       used. Globbing rules match .gitignore globs. Precede a glob with a ! to exclude
       it.

Globs in .gitignore files are indeed standard Unix globs. The syntax is documented exhaustively here: https://docs.rs/globset/0.3.0/globset/#syntax

Also, do double quotes behave the same way?

I don't think I can answer this question. It depends on your shell. Bash, for example, most definitely treats '...' differently than "...".

All 2 comments

Should I assume globs work like Unix and * are wildcards?

Yes. As documented:

-g, --glob <GLOB>...                    
       Include or exclude files and directories for searching that match the given
       glob. This always overrides any other ignore logic. Multiple glob flags may be
       used. Globbing rules match .gitignore globs. Precede a glob with a ! to exclude
       it.

Globs in .gitignore files are indeed standard Unix globs. The syntax is documented exhaustively here: https://docs.rs/globset/0.3.0/globset/#syntax

Also, do double quotes behave the same way?

I don't think I can answer this question. It depends on your shell. Bash, for example, most definitely treats '...' differently than "...".

Thanks for such a fast reply, wow. Very helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

crumblingstatue picture crumblingstatue  路  3Comments

Offpics picture Offpics  路  3Comments

andschwa picture andschwa  路  3Comments

lexicalunit picture lexicalunit  路  3Comments

Deewiant picture Deewiant  路  3Comments