regular expression

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Mon Dec 25 18:33:05 EST 2006


On Mon, 25 Dec 2006 06:17:00 -0800, deviantbunnylord at gmail.com wrote:

> Hi folks, fairly new to the list(Python is my first programming
> language, so I'm fairly new to the world of programming too)but this is
> a question I've been wondering about since I started learning about the
> re module. Are regular expressions what makes mark up languages
> interpretable by webbrowsers?

Web browsers have to render HTML, which implies they must be able
to parse and interpret at least one markup language. _How_ they parse the
markup is up to the browser developers.

Since regular expressions are very good at certain types of text parsing,
and are widely available, it is probable that regular expressions are used
in some (many? all?) markup parsers, simply because it is widely available
and is a good tool for some (but not all) parsing tasks. For example,
Python's xmllib module uses reg exps to parse xml.

Essentially, a regular expression engine is a super-charged "find"
command on steroids. But that doesn't mean that reg exps are the only tool
for the job. A markup parser doesn't necessarily need to use regexes.


-- 
Steven.




More information about the Python-list mailing list