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 7160217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:21:48+00:00 2026-05-28T13:21:48+00:00

My html code has many anchors and links such as : <script src=/Common/Scripts/jquery-1.4.4.min.js type=text/javascript></script>

  • 0

My html code has many anchors and links such as :

<script src="/Common/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>  
<link href="/Common/Css/UserAdmin.css" rel="stylesheet" type="text/css" />
<a href="/test.php">test</a></li> 

I want to change them into:

<script src="http://www.mydomain.com/Common/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>  
<link href="http://www.mydomain.com/Common/Css/UserAdmin.css" rel="stylesheet" type="text/css" />
<a href="http://www.mydomain.com/test.php">test</a></li> 

ie. add a http://www.mydomain.com before every src and href value, how to achieve this using regex expression. PS: I use PHP language.

  • 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-05-28T13:21:49+00:00Added an answer on May 28, 2026 at 1:21 pm

    Use the following regexp:

    ([\b]*)(src|href)([\b]*=[\b]*")(.+?")
    

    and replace with:

    \1\2\3http://www.mydomain.com\4
    

    The main idea here is to use the lazy operator “+?”

    Group1: ([\b]*)          0 or more blanks ... followed by 
    Group2: (src|href)       src or href ... followed by 
    Group3: ([\b]*=[\b]*")   0 or more blanks followed by = followed by 0 or more blanks followed by a quote ... followed by 
    Group4: (.+?")           any group of characters until the nearest quote
    

    then replace with what has matched Group1 then Group2 then Group3, insert http://www.mydomain.com, then what has matched Group4

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a rich text editor that has to handle pasted HTML code from MS
I am using jQuery and Ajax. My MainFile has the following code: <html> <head>
We have html page, it has many code inside. Sometimes it has block #container
I have html code like this <tr class=odd> <td><b>Reason for Termination:</b></td> <td>this has bunch
I'm learning PHP. The PHP has inline commands in HTML code to produce dynamic
I have a HTML file that has code similar to the following. <table> <tr>
i have create a form (so it's PHP and HTML hybrid-code). it has ability
I'm maintaining some code that has far too many document.write instances. For example, the
Good Afternoon, I have a html aspx page that has many many div elements.
When I write client side code, I use HTML/CSS/JavaScript and lately jQuery to both

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.