Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Match a regular expression

Reply
Thread Tools

Match a regular expression

 
 
whiskey
Guest
Posts: n/a
 
      03-02-2007
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

 
Reply With Quote
 
 
 
 
Martijn Lievaart
Guest
Posts: n/a
 
      03-02-2007
On Fri, 02 Mar 2007 08:57:04 -0800, whiskey wrote:

> 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
 
Reply With Quote
 
 
 
 
whiskey
Guest
Posts: n/a
 
      03-12-2007
There's probably no way to do this using solely a regular expression.
Thank you for your answers.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression - looking to match 'www' only if it is the start of a URL hooterbite@yahoo.com ASP .Net 0 07-20-2005 04:11 PM
Regular Expression - looking to match 'www' only if it the start of a URL hooterbite@yahoo.com ASP .Net 4 07-12-2005 01:01 PM
how to match regular expression from right to left Liang Perl 2 08-27-2004 10:03 PM
match three digit number using regular expression championsleeper Perl 6 04-06-2004 08:54 PM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments