Pattern extraction

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Sorry i didnt explain the previous posy correctly.

I am having a string which can have either one of the below as its

          $str="/a/b/c/"; (or) $str = "/a/b/c/d/";

What i need is that regardless of the input it should always be able
to extract "c" from the
above strings. I should not use split. Only by using regular
expressions i should be able to achieve this. Please help me to solve


Re: Pattern extraction

[ You keep starting new threads for the same problem. Don't do that!! ]

Deepan - M.Sc(SE) - 03MW06 wrote:
Quoted text here. Click to load it

Says who?

Quoted text here. Click to load it

split() does make use of a regular expression...


     if ( $str =~ m#^/[^/]+/[^/]+/([^/]+)# ) {
         print "$1\n";

Gunnar Hjalmarsson

Site Timeline