Hi Robert

Thanks very much for your reply.

Unfortunately, as you say, the expression won't work in situations
where there's a closing brace within the function (eg., delimiting the
end of the a case function, or a for....loop)

But, the idea of employing the function / class statement in the
opening certainly helps with eliminating some of the nesting.

Thanks again for your input, it's greatly appreciated

Cheers

Marty

--- In flexcoders@yahoogroups.com, "Robert Stehwien" <[EMAIL PROTECTED]>
wrote:
>
> For functions use a regular expression like: function[\s\S]*{[\s\S]*}
> 
> This looks for function followed by zero or more of any character
(including
> newlines), followed by {, followed by zero or more of any character
> (including newlines), followed by }.
> 
> For classes replace "function" with "class" above.
> 
> FYI: I use RegEx Buddy to help me with my regular expressions
> http://www.regexbuddy.com/
> 
> (I am in no way affiliated with the company, just like the product).
> 
> I tested the function expression in that tool for JavaScript and it
seemed
> to work even when nesting.
> 
> What it wouldn't help you with is if you nested functions within
functions
> (like when declaring a function object).  But I don't have time to
fiddle
> with that right now.
> 
> --Robert
> 
> On Thu, Feb 14, 2008 at 6:22 AM, marty.pitt <[EMAIL PROTECTED]> wrote:
> 
> > Hi
> >
> > Can someone please give me a hand on a RegEx?  (I can't work these
> > things out for the life of me).
> >
> > I'm basically trying to return nested groups inside delimeters.
> >
> > An example we're all famililar with is the simple package / class
> > structure in Flex:
> >
> > package foo {
> >   class bar {
> >      function stuff {
> >        ...
> >      }
> >    }
> > }
> > Given the delimeters oof { and }, I want to be able to return:
> > function stuff {
> > ...
> > }
> >
> > As well as
> >
> > class bar {
> >      function stuff {
> >        ...
> >      }
> >    }
> >
> > etc., up the chain.
> >
> > I currently have the following regex working:
> >
> > {\d*?\D*?}
> >
> > Which works fine without nesting.  As soon as you introduce nested
> > elements, it all gets a bit messy.
> >
> > any help would be greatly appreciated.
> >
> > Cheers
> >
> > Marty
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
>


Reply via email to