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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -