Search in paragraph's text: Difference between revisions

m
(→‎{{header|Raku}}: expand into a complete solution)
Line 117:
Using the awk "Record Separator" :
<lang awk>
awk 'BEGIN { RS = "" ; ORS = "\n----------------\n" } \/Traceback/ && /SystemError/ { print substr($0,index($0,"Traceback")) }' Traceback.txt
/Traceback/ && /SystemError/ \
{ print substr($0,index($0,"Traceback")) }' Traceback.txt
</lang>
Note : RS is modified from "\n" to "" in order to use Traceback information in index function.
 
ORS is modified to seperate the paragraphs with "\n----------------\n"
 
Each paragraph must contains "Traceback" and "SystemError"
 
substr is extracting only characters after "Traceback" appearance, until the next matching "Traceback" and "SystemError".
 
40

edits