<div dir="ltr"><div><br></div>Ah, regex golf. Try 'def.*buff.*for.*ALTPLAN' Use "grep -i" to ignore case. Your initial regexp used *file* regex, where "*" means any character any length. In the proper formal dialects, "*" merely means any number of the preceding RE, and the "." means any character. Hence, "foo*" in the shell matches "fooa","foob", et cetera. But in regex, it matches only "foo", "fooo", "foooooo", et cetera. Watch out for quoting in the shell also; that's why I used single-quotes. Knowing just a few REs can carry you a surprising distance. [abc] matches the single character a,b,and c. So "[abc]+" matches aaaa, bb, or ccc but not i.<div><br></div><div><div><br></div><div>This worked for me on the following file:<div><br></div><div><div>define buffer snort for ALTPLAN</div><div>DEFINE BUFFER BOOF for ALTPLAN</div><div>FOO</div><div><br></div></div><div><div>!:/home/cshapiro/Mapping_Contracts/forsythco> grep -i '^def.*buf.*for ALTPLAN' foo.txt</div><div>define buffer snort for ALTPLAN</div><div>DEFINE BUFFER BOOF for ALTPLAN</div></div><div><br></div><div>For extra fnu, try the regex golf site ( <a href="http://www.regex.alf.nu/">http://www.regex.alf.nu/</a> ).</div><div><br></div><div>-- CHS</div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 22, 2016 at 8:35 PM, DJ-Pfulio <span dir="ltr"><<a href="mailto:DJPfulio@jdpfu.com" target="_blank">DJPfulio@jdpfu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'd use perl. Trivial to read a file, find the lines matching any<br>
complex regex you like, back up 3 lines and print the following 14 lines.<br>
Don't forget to handle lines that happen inside the group to be<br>
exported. Would be good to show file:linenum:LINE so it is clear -<br>
perhaps highlight the actual line with << >> - idunno.<br>
<br>
I like Leam's regex except the leading ^ and trailing $ - these things<br>
don't need to start in col-1 or end of line. Otherwise, probably<br>
restrictive enough to minimize unwanted output.<br>
<span class="im HOEnZb"><br>
On 09/22/2016 07:30 PM, Leam Hall wrote:<br>
> Why not "^def*buff*altplan$"? Then grep v out things you don't want.<br>
><br>
> On 09/22/16 14:46, Neal Rhodes wrote:<br>
>> So, I need to look in about a bazillion source files for variants of<br>
>><br>
>> DEFINE BUFFER SNORT FOR ALTPLAN.<br>
>> Define Buffer Blech for AltPlan.<br>
>> Def Buff Blurf for AltPlan.<br>
>> Def Buff Blurf for AltPlan.<br>
>> def buff blurf for altplan.<br>
>> define buff blurf for altplan.<br>
>> define buffer blorf for<br>
>> altplan.<br>
>> define new shared buffer blorf for altplan.<br>
>><br>
>> And grap 3 lines before, 10 lines afterwards, source file and line#.<br>
>><br>
>> I was thinking this would to it:<br>
>><br>
>> grep -i -B 3 -A 10 -H -n -r -f buf-grep.inp * > buf.grep.out<br>
>><br>
>> Where buf-grep.inp was<br>
>><br>
>> def*buff*for*ALTPLAN<br>
>><br>
>> def*buff*for*ARM<br>
>><br>
>> def*buff*for*ARMNOTE<br>
>><br>
>> Alas it is not thus, and the more I study the reg exp notes the more I<br>
>> see there error of my ways, and the less I see an expression that would<br>
>> work.<br>
>><br>
</span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/<wbr>listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/<wbr>listinfo</a><br>
</div></div></blockquote></div><br></div>