Regexp problem

Discussion in 'Perl Misc' started by chatiman, Feb 28, 2004.

  1. chatiman

    chatiman Guest

    Hello,

    I'd like to match a line which does not begin with a given words and match a
    given regexp.
    eg:
    lines which contains "bar" but does not begin with "foo"

    I tried the following regexp but this doesn't work:
    /^(?<!foo).*bar/

    Any ideas to do that in 1 regexp?
    chatiman, Feb 28, 2004
    #1
    1. Advertising

  2. chatiman <> wrote:

    > lines which contains "bar" but does not begin with "foo"
    >
    > I tried the following regexp but this doesn't work:
    > /^(?<!foo).*bar/



    You are looking in the wrong direction.


    > Any ideas to do that in 1 regexp?



    /^(?!foo).*bar/


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 28, 2004
    #2
    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. Greg Hurrell
    Replies:
    4
    Views:
    149
    James Edward Gray II
    Feb 14, 2007
  2. Mikel Lindsaar
    Replies:
    0
    Views:
    463
    Mikel Lindsaar
    Mar 31, 2008
  3. Joao Silva
    Replies:
    16
    Views:
    338
    7stud --
    Aug 21, 2009
  4. Uldis  Bojars
    Replies:
    2
    Views:
    185
    Janwillem Borleffs
    Dec 17, 2006
  5. Matìj Cepl

    new RegExp().test() or just RegExp().test()

    Matìj Cepl, Nov 24, 2009, in forum: Javascript
    Replies:
    3
    Views:
    169
    Matěj Cepl
    Nov 24, 2009
Loading...

Share This Page