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