Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
regular expression to extract text
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Fredrik Lundh, post: 1738821"] here's one way to do it: data = """ Using unit cell orientation matrix from collect.rmat NOTICE: Performing automatic cell standardization The following database entries have similar unit cells: Refcode Sumformula <Conventional cell parameters> ------------------------------------------ QEXZUO C26 H31 N1 O3 6.164 15.892 22.551 90.00 90.00 90.00 ------------------------------------------ ARQTYD C19 H23 N1 O5 6.001 15.227 22.558 90.00 90.00 90.00 ------------------------------------------ NHDIIS C45 H40 Cl2 6.532 15.147 22.453 90.00 90.00 90.00 """ from StringIO import StringIO file = StringIO(data) for line in file: if line.startswith("---"): part1, part2 = file.readline().strip().split(None, 1) part3 = file.readline().strip() print "1.", part1 print "2.", part2 print "3.", part3 </F> [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
regular expression to extract text
Top