regex - match anything until

Discussion in 'Perl Misc' started by John, Sep 10, 2009.

  1. John

    John Guest

    Hi

    Let's say I have a string:

    Ann ddsddfdf;,f,ef.we;r,asfdfdsff Bob dasd,@d&asdasodkasm,das Charles

    =~ m |Ann([.]+)Bob([.]+)Charles|

    I'm trying to extract the two strings between the 3 names.

    It doesn't work. What is the construct for 'anything until the string Bob'

    Regards
    John
    John, Sep 10, 2009
    #1
    1. Advertising

  2. John

    John Guest

    "Tad J McClellan" <> wrote in message
    news:...
    > John <> wrote:
    >
    >> Ann ddsddfdf;,f,ef.we;r,asfdfdsff Bob dasd,@d&asdasodkasm,das
    >> Charles
    >>
    >>=~ m |Ann([.]+)Bob([.]+)Charles|

    > ^ ^ ^ ^
    > ^ ^ ^ ^ dot is not meta when in a character class
    >
    >> I'm trying to extract the two strings between the 3 names.
    >>
    >> It doesn't work.

    >
    >
    > Remove the square brackets.
    >
    >
    >> What is the construct for 'anything until the string Bob'

    >
    >
    > /(.*)Bob/s
    >
    > The construct for 'anything except newline until the string Bob' is:
    >
    > /(.*)Bob/
    >
    >
    >
    > --
    > Tad McClellan
    > email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"



    Many thanks. I can see my mistake.

    Regards
    John
    John, Sep 10, 2009
    #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. hiwa
    Replies:
    0
    Views:
    631
  2. anon1m0us

    Match until new line

    anon1m0us, Feb 7, 2007, in forum: Ruby
    Replies:
    4
    Views:
    84
    Brian Candler
    Feb 7, 2007
  3. Lydia Shawn

    get (url) until match is found

    Lydia Shawn, Jan 26, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    103
    Brian McCauley
    Jan 26, 2004
  4. S P Arif Sahari Wibowo
    Replies:
    3
    Views:
    116
    S P Arif Sahari Wibowo
    Jul 2, 2006
  5. S P Arif Sahari Wibowo
    Replies:
    1
    Views:
    98
    Joe Smith
    Jul 2, 2006
Loading...

Share This Page