Help for this page

Select Code to Download


  1. or download this
    ($domain) = split '/', $string;
    $wanted = (split /\./, $domain)[-2];
    ...
    # or
    
    $wanted = (split /\./, (split '/', $string)[0])[-2];
    
  2. or download this
    ($wanted) = $string =~ m{
      ( [^.]+ )   # save the non-. sequence to $1
    ...
      [^./]+      # the final non-. non-/ sequence
      (?: / | $)  # / or the end of the string
    }x;