how to match regular expression from right to left

Discussion in 'Perl' started by Liang, Aug 26, 2004.

  1. Liang

    Liang Guest

    hi, I'm a newbie to perl :p

    I want to parse this kind of string:
    /main/abcd/efgh/hhh/3

    to get the rightmost string that is enclosed in '/'. In this case, it's
    'hhh'.

    So, how to do this in Perl? something as '=~ /\/(.*)\//' ?

    or use index()?

    Thanks in advance,
    Liang
     
    Liang, Aug 26, 2004
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, Aug 26, 2004
    #2
    1. Advertising

  3. Liang

    Guest

    "Liang" <> wrote in message news:<cgkavf$fop$>...
    >
    > I want to parse this kind of string:
    > /main/abcd/efgh/hhh/3
    >
    > to get the rightmost string that is enclosed in '/'. In this case, it's
    > 'hhh'.
    >
    > So, how to do this in Perl? something as '=~ /\/(.*)\//' ?


    /.*\/(.*)\//

    This newsgroup does not exist (see FAQ). Please do not start threads here.
     
    , Aug 27, 2004
    #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. VSK
    Replies:
    2
    Views:
    2,338
  2. =?Utf-8?B?QmlzaG95?=
    Replies:
    0
    Views:
    1,005
    =?Utf-8?B?QmlzaG95?=
    Dec 28, 2006
  3. Oran
    Replies:
    2
    Views:
    561
  4. Philip Primak
    Replies:
    3
    Views:
    102
    Veli-Pekka Tätilä
    Aug 7, 2005
  5. Replies:
    13
    Views:
    212
    robic0
    Aug 27, 2006
Loading...

Share This Page