pattern mattching

Discussion in 'Perl Misc' started by Pascal, Feb 13, 2004.

  1. Pascal

    Pascal Guest

    I'm try to match a pattern which doesn't really work for me kuz I just
    want the pattern to appear once for example I have this line:

    int x=0;x<=100;x++

    I only what this: =, <=, ++
    but I get all of these: =,<,=,<=,+,+,++
    because In an other line I could have this: y=x+y then I would like to
    have:=,+
    but I can't seem to figure out what pattern to use That would work for
    all situation.
    Pascal, Feb 13, 2004
    #1
    1. Advertising

  2. Pascal

    Anno Siegel Guest

    Pascal <> wrote in comp.lang.perl.misc:
    > I'm try to match a pattern which doesn't really work for me kuz I just
    > want the pattern to appear once for example I have this line:
    >
    > int x=0;x<=100;x++
    >
    > I only what this: =, <=, ++
    > but I get all of these: =,<,=,<=,+,+,++


    So what pattern are you using?

    > because In an other line I could have this: y=x+y then I would like to
    > have:=,+


    Looks like you're after the operators in C code. If so, why don't
    you say so?

    > but I can't seem to figure out what pattern to use That would work for
    > all situation.


    What are "all" situations?

    If my assumption is right that you want to parse C code for operators,
    pattern matching won't do. You'll need a parser. Your best best is
    probably Parse::RecDescent. There may even be (partial) C parsers
    on CPAN.

    Anno
    Anno Siegel, Feb 13, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    17
    Views:
    1,865
    Chris Uppal
    Nov 16, 2005
  2. sunny
    Replies:
    1
    Views:
    461
    Salt_Peter
    Dec 7, 2006
  3. Pallav singh
    Replies:
    0
    Views:
    358
    Pallav singh
    Jan 22, 2012
  4. Pallav singh
    Replies:
    0
    Views:
    399
    Pallav singh
    Jan 22, 2012
  5. Pallav singh
    Replies:
    1
    Views:
    449
    Peter Remmers
    Jan 22, 2012
Loading...

Share This Page