Regexp optimization question
William Park
opengeometry at yahoo.ca
Fri Apr 23 21:24:33 EDT 2004
Magnus Lie Hetland <mlh at furu.idi.ntnu.no> wrote:
> In article <c6brgc$a70l0$1 at ID-99293.news.uni-berlin.de>, William Park wrote:
> [snip]
> >
> >Since you want both the matched strings and their locations in file, you
> >pretty much have to this manually, one by one.
>
> Well -- that's more or less what I'm doing. (Or -- I can get the match
> objects all at once, of course, using finditer.)
>
> I guess I'll have to look elsewhere for performance improvements. Hm.
You can write up something in C, as standalone or as patch to Bash
shell. Essentially,
- locate start of string match
- print location (and the string)
- move pointer past the end of string.
- repeat.
Closest you can do using standary tools is strings and byte-offset of
the lines the strings occurs.
--
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution/training/migration, Thin-client
More information about the Python-list
mailing list