Python regex to extract data from string -
i have text file, lines of following form:
c="etc etc etc" 124:1 124:1||r="trnap etc"||c="etc etc" 124:10 124:10
the text in quotes changes line line, numbers. otherwise format constant. numbers indicate line number , word number (line#:word#)
of text in quotes in other document.
can provide example regex code extract line#:word#
numbers? thanks!
>>> import re >>> c = '"etc etc etc" 124:1 124:1||r="trnap etc"||c="etc etc" 124:10 124:10' >>> print re.findall(r"(\d+):(\d+)", c) [('124', '1'), ('124', '1'), ('124', '10'), ('124', '10')]
Comments
Post a Comment