By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

Building several parsing modules

P: n/a
Basically, I want to create a table in html, xml, or xslt; with any
number of regular expressions; a script (Perl or Python) which reads
each table row (regex and replacement); and performs the replacement
on any file name, folder, or text file (e.g. css, php, html). For
example, I often rename my mp3 (files); the folder holding the mp3
files; and replace these renamed values in a playlist/m3u/xml file.

The table should hold clean regular expressions with minimal escaping.
The regular expressions would incorporate multiple lines and complex
expressions (e.i. symbolic grouping, back referencing, negative
lookahead). The table would serve as a preset file for any replacement
task. It also contains short description column for each regular
expression. The table could contain 1 to 1000 regular expressions; and
the input file could have 1000 to ten thousand lines as well. SED
would become messy here.

I am just starting out with building the logic and pseudo-code. I am
hoping for any examples where these libraries have been applied. Links
and guides would help since I am just starting out with the language.
I need suggestions and examples on reading input by line; managing
large data sets; iterating through an xml/html structure; and various
parsing techniques.

I built a solution in VBScript and VBA, but it had several limitations
like operating on one platform and did not have full Perl regular
expression support. In addition, it is attached to an Access database.
The solution would parse and add headers to the data. It would parse
the data with the headers and insert it into a table. It had over
fifteen modules for repetitive parsing tasks to build a importable
data set. VBScript Regexes are not as powerful as Perl or even sed.

This request is large, yet someone with command of the language could
give guidance on the basic framework to kickstart my efforts.
Basically, I need someone to say start here; then proceed to this
function; then look into these libraries; so on.
Mar 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Robert Neville wrote:
Basically, I want to create a table in html, xml, or xslt; with any
number of regular expressions; a script (Perl or Python) which reads
each table row (regex and replacement); and performs the replacement
on any file name, folder, or text file (e.g. css, php, html). For
example, I often rename my mp3 (files); the folder holding the mp3
files; and replace these renamed values in a playlist/m3u/xml file.
<snip/>

Don't do it. Just write python for the task at hand - if it involves regular
expressions, use the re module if you must, but lots of stuff can be done
with simpler, less confusing means like string.split and the like.

The result should be a small few-liner. You are way better off with that,
especially when you have to take constraints into account like moon phase
or the like - you then have the full power of python at your hand, instead
of inventing some wicked table-based "language" that you code exceptions
into.

Diez
Mar 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.