Today I am asking guidance on a quest. The guidance has to do with efficiency, flexibility and/or speed. It concerns searching for matches of multiple Regexps in a large document. This is not homework, and I am looking for prior empirical experience. I have to assume this path has been trodden before, or it wouldn't be a path.
- the document is in a scalar and may be 4-10K in size and possibly structured only approximately like XML
- 20-80+ different Regexps to test for
- Regexps are simple to moderately complex (look-around, tag nesting, etc).
- All occurrences of a each Regexp are to be found.
- Regexps are loaded from a configuration file,no prior knowledge of what will be there.
Approach 1 -- over full document, 1 regexp at a time.
Approach 2 -- dynamically build huge 'alternation'(re1|re2|re3|re4|...), over document once.
Approach 3 -- use while ( $doc =~ m/\G\z/gc) { ....} loop structure for incremental over document once.
As I write this, the thought that RE3 might be a subset of RE18; and I might want to know about both.
It is always better to have seen your target for yourself, rather than depend upon someone else's description.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.