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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:20:08+00:00 2026-05-26T18:20:08+00:00

I want to locate all image tags in my html with src not containing

  • 0

I want to locate all image tags in my html with src not containing http:// and prepend http:// to the src attribute.

I have got the regex to find all img tags not starting with http://. I’m having some trouble appdening http:// to the src attribute alone. How can I achieve this using regex replace.

<img [^<]*src="(?!http://)(?<source>[^"]*)"[^<]*/>

Source will contain the src value. I just need it to say $2 = "http://" + $2. How can I write this in c# code.

  • 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-26T18:20:09+00:00Added an answer on May 26, 2026 at 6:20 pm

    Since you don’t want to break existing tags, you will need to assign groups to the parts of the string you are not interested in; in order to be able to include those parts of the match in the replace pattern:

    (<img [^<]*src=")(?!http://)(?<source>[^"]*)("[^<]*/>)
    

    Then the replace is trivial:

    regex.Replace(input, "$1http://$3$2");
    

    (Also, this might work for your application use case, but I should mention, that in general it is not considered a good idea to parse HTML with regex)

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

Sidebar

Related Questions

I have an ip address i want to locate all the nearest places ip
I want to centrally locate all of my application settings in the database. I
I have an image and I want to calculate the average gray value of
I've got a XML file and I need to locate all parameters with parameterid
I have a page which have lots of addresses. I want to have 'locate'
I write 2 GWT module and compile it. I want locate ***.nocache.js files into
I have an Access 2003 database MDB where all of the tables exist as
I have a cell with fixed height and I want the font size of
I have implemented some utility classes in Flex that I want to use in
I have several images that i want to be Embedded into the exe. When

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.