Thanks much.

On 3/26/07, Jake McGraw <[EMAIL PROTECTED]> wrote:

To quote Mastering Regular Expressions 3rd Ed. by J. Friedl:

The real problem is that on the majority of systems, you simply can't
match arbitrarily nested constructs with regular expressions.

He goes on to give the syntax for matching a SINGLE set of nested
parenthesis, it's quite convoluted.

Kenneth is right, you have to use one of the recursive expressions
built into PHP (or Perl or .NET) or you could create your own balancer
using a stack.

- jake

On 3/20/07, Daemach2 <[EMAIL PROTECTED]> wrote:
>
> I'm working on a regular expression to do syntax highlighting and I just
ran
> into a problem.
>
> The regular expression below works on just about everything except
nested
> parentheses:
>
>
(</*cf\w+)\s*((?:\w+\s*?)|(?:\w+\s*=\s*["'][^"']*["']\s*?)|(?:\w+\([^)]+\)))*(/*>)
>
> Will match:
>
> <cfif isDefined('form.fieldnames')>
>
> <cfheader name="Content-Type" value="text/xml">
>
> <cfcontent type="text/xml" reset="yes">
>
> <cfset lacking = "">
>
> <cfloop list="#form.fieldnames#" index="i">
>
> <cfif not listLen(lacking)>
>
> but not
>
>  <cfif not isNumeric(evaluate(i))>
>
>
> I'm not sure what to do about nested parens because nested functions can
get
> pretty complex :/  Any thoughts?
>
> This is the block that is supposed to deal with those:  (?:\w+\([^)]+\))
>
> Oh yeah, and is there any way to make the 2 key/value pairs in the
following
> tag show up as separate matches?  At the moment, the index="i" capture
> overwrites the first pair.  Or do I just need to loop over an exec to
handle
> those separately?
>
> <cfloop list="#form.fieldnames#" index="i">
> --
> View this message in context:
http://www.nabble.com/Any-regular-expression-gurus-here--tf3437744.html#a9585509
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to