Building several parsing modules

R

Robert Neville

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.
 
D

Diez B. Roggisch

Robert said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top