pattern mattching

P

Pascal

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

Anno Siegel

Pascal said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top