You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by Omair-Inam Abdul-Matin <oi...@cs.uwaterloo.ca> on 2006/05/30 00:32:30 UTC
Regular expression question
I would like to catch the following pattern:
A substring in the file beginning with the pattern "Importing file" and
ending with the pattern "Modified.*rows in.*table", possibly spanning
multiple lines provided that it contains the string Exception. The
substring should not contain the beginning or ending patterns more than
once...
The following command almost works, except that it may return strings
that contain "Importing file" multiple times:
perl -0777ne "print m!Importing
file[\s\S]*?Exception[\s\S]*?Modified.*table!g;" test.txt
Does anyone know what changes I could make to the regular expression so
that it prints out the correct pattern?
I've attached a small test document for anyone wanting to test out ideas.
Thanks,
Omair