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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -