[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: parsing parens in the park

Subject: Re: parsing parens in the park
From: Liam Quin <liam@xxxxxx>
Date: Sun, 28 Sep 2008 17:15:35 -0400
Re:  parsing parens in the park
On Sun, Sep 28, 2008 at 09:15:45PM +0100, David Carlisle wrote:
> You can not match nested brackets with regular expressions. (That's more
> or less the defining restriction which is implied by "regular").

Agreed...

> To match brackets you need to use, in addition to regular expressions, a
> language that can either count or (equivalently) has a unbounded stack.
> (Eg recursive function calls).

Actually if all you need to do is test to see if they match or not,
you can do easier things.  In an iterative language,
    while (string has parens) {
        remove all occurrences of "()"
	if there were none, signal an error
    }
    if you get here without error, it's OK.

The XSLT implementaion of this would be recursive though.

Perl regexps can mach parens, and there's an example in the
"perldoc perlre" or, "man perlre" documentation.

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/ * http://www.fromoldbooks.org/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.