Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:57:41+00:00 2026-06-09T11:57:41+00:00

so what I want to do is remove everything after and including the first

  • 0

so what I want to do is remove everything after and including the first “/” to appear after a “.”
so: http://linux.pacific.net.au/primary.xml.gz
would become: http://linux.pacific.net.au

How do I do this using regex? The system I’m running on can’t use URI tool.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:57:42+00:00Added an answer on June 9, 2026 at 11:57 am

    I suggest you use URI::Split which will separate a standard URL into its constuent parts for you and rejoin them. You want the first two parts – the scheme and the host.

    use strict;
    use warnings;
    
    use URI::Split qw/ uri_split uri_join /;
    
    my $scheme_host = do {
      my (@parts) = uri_split 'http://linux.pacific.net.au/primary.xml.gz';
      uri_join @parts[0,1];
    };
    
    print $scheme_host;
    

    output

    http://linux.pacific.net.au
    

    Update

    If your comment The system I’m running on can’t use URI tool means you can’t install modules, then here is a regular expression solution.

    You say you want to remove everything after and including the first “/” to appear after a “.”, so /^.*?\./ finds the first dot, and m|[^/]+| finds everything after it up tot he next slash.

    The output is identical to that of the preceding code

    use strict;
    use warnings;
    
    my $url = 'http://linux.pacific.net.au/primary.xml.gz';
    
    my ($scheme_host) = $url =~ m|^( .*?\. [^/]+ )|x;
    
    print $scheme_host;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove everything after and including the decimal, and everything non-numerical except
I have a simple xml file and I want to remove everything before the
Hi I have movie titles and I want to remove everything after the empty
I want to remove everything before and after form . I am new in
I have a string with two - 467.2-123-hdxdlfow I want to remove everything after
I have a string: HLN (Formerly Headline News) I want to remove everything inside
I want to remove the string code=hads1328fas& on my URL, so that BEFORE http://example.com/main/index.php?code=hads1328fas&store=food#home
Let's say I have some email: some_email@yahoo.com . Firstly I would want to remove
I want to remove a specific context menu item, appears when the Mouse down(right)
I want to remove the braces so {test} becomes test. I tried {test}.gsub(/\{(.*)\}/,$1) while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.