Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to match this URL but Its not working not matching at all ...

My Code is wrong but can somebody correct it for me ?

if (($u =~ /turbobit/) && (m/^http:\/\/(([A-Za-z]+[0-9-.]+)*?)([a-z]*\.[^\/]{3}\/[a-z]*\/[0-9]*)\/(.*?)\/([^\/\?\&]{4,})$/)) {
    print $x . "http://cdn." . $3 . "/SQUIDINTERNAL/" . $5 . "\n";

I want to store rewrite the uRL into :

I know It must work in other way like we can put (name=*?) into an element and then we can use it !

share|improve this question

It's not quite clear what you're trying to match here, as your regex implies you're trying to match more generally than your conditional and examples seem to indicate. I'm going to assume for the sake of my answer that you're looking for stuff coming from any subdomain of turbobit (under any TLD, any port) served by /download.php with a name parameter set.

# unless you really just want to match anything with turbobit in the url
# you should do this more explicitly
if ($u =~ m,http://(?:[^/]+\.)?turbobit\.[^/]+/,) {
    # this conditional will be clearer if you break it up

    # we're using the non-capture notation for most of these because it didn't
    # look like you were actually using this data.
    if ($u =~ m,^http://(?:[A-Za-z]+[0-9-]+\.)?turbobit\.[^/:]+(?::\d+)?/download\.php.*[?&]name=([^&]+),) {
        my $name = $1;

        # you can use the concatenate operator, but why not just interpolate?
        print "${x}${name}\n";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.