> Friends, >Could someone please give some hint on how to extract lines between two >patterns in a file. I use the re module to compile my patterns but not able to >figure out how i can use these patterns to extract the lines lying in between.
Not sure exactly what you want but something like this could work. Note, this is not memory efficient. line = file.read() index1 = line.find( PATTERN1 ) index2 = line.find( PATTERN2 ) in_between = line[index1 + len( index1 ):index2] number_of_lines = len( in_between.split() ) # -1 ? # might need to adjust (-1) to avoid the line PATTERN1 is on Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor