how to match regular expression from right to left

L

Liang

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
 
N

nobull

Liang said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top