Hi, I have a problem where I need to print on STDOUT only certain parts of the string matched by a regex.
I am able to achieve that if I use the --only-matching (-o) option but not via a regex, it would be really great if you can tell me if there is a way or not. I cannot use the -o option as pcregrep is inside of another program where it only accepts the regex. Here is what I am looking for STRING #ABC_XYZ foo.c(999) @ 19990 ns: foobar [foo] DATA packet mismatch..... Data on wire is 0000000000000000000000000000063b0000000000000000000000000000063b0000000000000000000000000000063b0000000000000000000000000000063b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 I want to print out just the line #ABC_XYZ foo.c(999) @ 19990 ns: foobar [foo] DATA packet mismatch..... I am able to do this if I do the below % pcregrep -o -e "#\s+ABC_XYZ.*\.\.\.\." file.txt #ABC_XYZ foo.c(999) @ 19990 ns: foobar [foo] DATA packet mismatch..... But need a way to do the above without using '-o' option I went through the documentation and did quite a few experiments but could not find a method. Your help is greatly appreciated. Thanks Raga -- ## List details at http://lists.exim.org/mailman/listinfo/pcre-dev
