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

  • SEARCH
  • Home
  • 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 8262555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:47:35+00:00 2026-06-08T03:47:35+00:00

I want to extract all the urls from an XML file, excludeing the the

  • 0

I want to extract all the urls from an XML file, excludeing the the tracking code in the url:

Here’s an example of a URL, they all follow the same format

http://www.domain.com.au/category/pXXXXXX?uni_id=XXXXXX&cid=1_demo_1

So the only thing that changes between the domains is XXXXXX which is a numerical value

The end result I want is

http://www.domain.com.au/category/pXXXXXX

I have tried to use preg_replace in the below code but it ended up replacing the whole URL with a random (i think) number

$data = preg_replace('/http\:\/\/www\.domain\.com.au\/[^\?]+([^.]+)/','',$data);
  • 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-08T03:47:37+00:00Added an answer on June 8, 2026 at 3:47 am

    Match URLs in the XML with preg_match():

    preg_match("(http://[^\s]+|ftp://[^\s]+)", $input, $matches);
    

    Then, you should use preg_replace() and should only match the part of the string that needs to be removed:

    foreach($matches as $value)
    {
        preg_replace("(\?[^\s]+)","",$value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example url: http://p.static.com/i/logo.jpg I want to be able to extract the urls from my
I want to extract all the properties from my pom.xml into a properties-file. These
I want to extract all tags in a xml file. However, I cannot write
I want to extract all data from an Excel file to a SQL Server
I want to extract attributes from an xml file using Sax Parser I am
I want to extract from a webpage all URLs how can I do that
I want to extract the file name 13572_BranchInformationReport_2012-06-28.zip from the following text - 1:30,/icons/def13572_BranchInformationReport_2012-06-28.zip,13572_BranchInformationReport_2012-06-28.zip,0,184296,Jun
I want to extract the value between the apostrophes, for example from this string:
I want to extract all the elements of a list from the first non-numeric
How do I extract all the dependencies from a Windows file in Python? So

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.