($match) = "The longest word" =~ /(\w+)/; print $match; #### ($match) = "Mrs Smith" =~ /(Mr|Mrs)/; print $match; #### ($match) = "/foo/bar" =~ m[.*/(.*)]; print $match; #### ($match) = "foo/bar/baz" =~ m[.*?/(.*)]; print $match; #### ($outer, $inner) = "/foo/bar" =~ m[(/(.+))*]; print $inner;