Created
June 13, 2014 20:21
-
-
Save mdeous/d3269b66d5d1cba526dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [23]: def find_offsets(filename, regex): | |
| ...: with open(filename) as ifile: | |
| ...: lineno = 1 | |
| ...: for line in ifile: | |
| ...: for result in regex.finditer(line): | |
| ...: print "Result found line %d column %d" % (lineno, result.start()) | |
| ...: lineno += 1 | |
| ...: | |
| In [24]: r = re.compile('=') | |
| In [25]: find_offsets('/home/mdeous/.bashrc', r) | |
| Result found line 15 column 41 | |
| Result found line 18 column 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment