dongre.avinash has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Regular expression for C statement
by davido (Cardinal) on Aug 04, 2012 at 19:40 UTC

    Let's back up a moment and forget you've ever heard about the existence of regular expressions, and even Perl. In fact, let's forget that you're trying to parse a C if statement. Try to answer these questions so that we can help guide you to an effective solution:

    What are you trying to accomplish?

    Why do you want to parse C statements?

    What will you do with the result?


    Dave

Re: Regular expression for C statement
by tobyink (Canon) on Aug 04, 2012 at 19:06 UTC

    Regular expressions are not the right tool for the job. You want a proper parser. Parse::RecDescent is probably sophisticated enough.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Regular expression for C statement
by Anonymous Monk on Aug 05, 2012 at 02:16 UTC

    Pardon me, but ... given a one-writeup poster with a (pardon me, but ...) most-decidedly Indian name ... this very-frankly sounds to me like an individual who “got the job on price alone,” who now is revealed as not having even the faintest idea how to do it.

    Please understand that I am in fact not trying to be cynical.   But, like it or not, here I am presented with ... not “I know what I am doing and I have a technical question,” but ... “I am a pretender (but I am real cheap and...) and I have not the faintest clue.”   Please help me do your job for you...

    The digital computer is the great equalizer.   It will find you out if you are an imposter.