in reply to A question on Regex

The regular expression is capturing the first string it encounters that does not contain a slash. That first string is "http:". Assuming you actually want to capture the last one, you can use the $ metacharacter to anchor the regular expression to the end of the string:

if($mystring =~ m!([^/]+)$!){

More information on metacharacters can be found in Regular Expressions in perlre or Simple word matching in perlretut.

Replies are listed 'Best First'.
Re^2: A question on Regex
by siddheshsawant (Sexton) on Mar 24, 2010 at 19:47 UTC

    ohh ya I have to anchor it ....thanks a lot for your suggestion !!!!!