Match a regular expression

Discussion in 'Perl Misc' started by whiskey, Mar 2, 2007.

  1. whiskey

    whiskey Guest

    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
     
    whiskey, Mar 2, 2007
    #1
    1. Advertising

  2. 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
     
    Martijn Lievaart, Mar 2, 2007
    #2
    1. Advertising

  3. whiskey

    whiskey Guest

    There's probably no way to do this using solely a regular expression.
    Thank you for your answers.
     
    whiskey, Mar 12, 2007
    #3
    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. championsleeper
    Replies:
    6
    Views:
    1,040
    championsleeper
    Apr 6, 2004
  2. Liang
    Replies:
    2
    Views:
    1,740
  3. VSK
    Replies:
    2
    Views:
    2,354
  4. Replies:
    4
    Views:
    746
  5. Replies:
    0
    Views:
    373
Loading...

Share This Page