Match a regular expression

W

whiskey

I couldn't find any help on the web (also tried on another group) and
I'm not sure if this is the right place to ask such things. However, I
think most Perl programmers know regular expressions well.

So, my question is: how do I match, using a regular expression,
another regular expression within a string ?

Example: given a string like "$foo =~ /regexp/"*, I want to split it
into tokens: TOK_VAR -> $foo, TOK_BINDOP -> =~, TOK_REGEXP -> /
regexp/. For this, I'm using regular expressions. So how do I match
the regular expression ? Sure, in this example it may be easy, but
what about a string like "$foo =~ /regexp/ && $bar =~ /pxeger/" ?

* No, I'm not writing a Perl interpreter, I just want to know if it is
possible to avoid parsing the string
 
M

Martijn Lievaart

I couldn't find any help on the web (also tried on another group) and
I'm not sure if this is the right place to ask such things. However, I
think most Perl programmers know regular expressions well.

So, my question is: how do I match, using a regular expression,
another regular expression within a string ?

Example: given a string like "$foo =~ /regexp/"*, I want to split it
into tokens: TOK_VAR -> $foo, TOK_BINDOP -> =~, TOK_REGEXP -> /
regexp/. For this, I'm using regular expressions. So how do I match
the regular expression ? Sure, in this example it may be easy, but
what about a string like "$foo =~ /regexp/ && $bar =~ /pxeger/" ?

* No, I'm not writing a Perl interpreter, I just want to know if it is
possible to avoid parsing the string

I'm pretty sure there is something on CPAN for this, but am to lazy to
look it up right now.

M4
 
W

whiskey

There's probably no way to do this using solely a regular expression.
Thank you for your answers.
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top