New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pcre2grep and a category for "does it match across multiple lines?" #74

Open
avar opened this Issue Jan 8, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@avar

avar commented Jan 8, 2018

As far as I know no other grep implementation can do this:

$ ./pcre2grep -M 'Copyright(\n|.)*Copying' INSTALL 
   Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Foundation, Inc.

   Copying and distribution of this file, with or without modification,
@petdance

This comment has been minimized.

Show comment
Hide comment
@petdance

petdance Jan 8, 2018

Collaborator

What is that doing? Multi-line match?

Collaborator

petdance commented Jan 8, 2018

What is that doing? Multi-line match?

@avar

This comment has been minimized.

Show comment
Hide comment
@avar

avar Jan 8, 2018

Yes, stand-alone example:

$ (echo foo; echo bar; echo baz) >file ;  ./pcre2grep 'foo.*baz' file; echo $?
1
$ (echo foo; echo bar; echo baz) >file ;  ./pcre2grep -M 'foo.*baz' file; echo $?
1
$ (echo foo; echo bar; echo baz) >file ;  ./pcre2grep -M 'foo(.|\n)*baz' file; echo $?
foo
bar
baz
0

I'm now aware of another grep-like tool that does this.

avar commented Jan 8, 2018

Yes, stand-alone example:

$ (echo foo; echo bar; echo baz) >file ;  ./pcre2grep 'foo.*baz' file; echo $?
1
$ (echo foo; echo bar; echo baz) >file ;  ./pcre2grep -M 'foo.*baz' file; echo $?
1
$ (echo foo; echo bar; echo baz) >file ;  ./pcre2grep -M 'foo(.|\n)*baz' file; echo $?
foo
bar
baz
0

I'm now aware of another grep-like tool that does this.

@BurntSushi

This comment has been minimized.

Show comment
Hide comment
@BurntSushi

BurntSushi Aug 7, 2018

The silver search does this (by default, nonetheless). ripgrep will also have this soon too.

BurntSushi commented Aug 7, 2018

The silver search does this (by default, nonetheless). ripgrep will also have this soon too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment