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. Advertisements

  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. Advertisements

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. Bill Yin

    re.Pattern = "\<p>(.[^\[]*)\<\/div>"

    Bill Yin, Jun 14, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    485
    Kalyan
    Jun 30, 2004
  2. C T
    Replies:
    3
    Views:
    2,792
    Charles M. Elias
    Mar 5, 2004
  3. Replies:
    17
    Views:
    2,162
    Chris Uppal
    Nov 16, 2005
  4. sunny
    Replies:
    1
    Views:
    654
    Salt_Peter
    Dec 7, 2006
  5. Pallav singh
    Replies:
    0
    Views:
    599
    Pallav singh
    Jan 22, 2012
  6. Pallav singh
    Replies:
    0
    Views:
    579
    Pallav singh
    Jan 22, 2012
  7. Pallav singh
    Replies:
    1
    Views:
    681
    Peter Remmers
    Jan 22, 2012
  8. ChrisC
    Replies:
    4
    Views:
    341
    ChrisC
    Jun 25, 2010
Loading...