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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -