Search_in_paragraph's_text.md 557 B

Search in paragraph's text

Generalized. Pipe in the file from the shell, user definable search term and entry point.

unit sub MAIN ( :$for, :$at = 0 );
 
put slurp.split( /\n\n+/ ).grep( { .contains: $for } )
         .map( { .substr: .index: $at } )
         .join: "\n----------------\n"

Output:

   raku search.raku --for='SystemError' --at='Traceback' < traceback.txt

Matches expected except for not having a extraneous trailing paragraph separator.