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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:45:33+00:00 2026-05-23T12:45:33+00:00

Hi again dear comminity! To make it short, I have a textbox, where you

  • 0

Hi again dear comminity!

To make it short, I have a textbox, where you can paste <img> tags, which look like this:
<img src="123.jpg" />.

Is there any way to make these <img> look this: <img src="img/upload/username/123.jpg" /> using jQuery .replace() or something like this ? Or should I use PHP function instead ?

I have tried to find out what jQuery .match() returns for some regual expression:

x = text.match(/\<img src="(.*)" \/>\$/);
alert(x);

,but it returns odd things, when there are more than one <img> tag.

Thank you for your help!

  • 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-23T12:45:34+00:00Added an answer on May 23, 2026 at 12:45 pm

    Not tested…

    $('#text').change(function(){
    
        $('img').each(function(){
            $(this).attr('src', '/img/upload/username/' + $(this).attr('src'));
        });
    
    });
    

    If you would like to do this on server side with PHP you can just replace like this, no need for regex…

    $text = str_replace('src="', 'src="/img/upload/username/', $text);
    

    Or if you would like to use regexp…

    $text = preg_replace('#"(.*?)\.jpg"#is', '"/img/upload/username/\\1.jpg"', $text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
( again annoying question... ) after asking this before - ( which is partly
Again me with my divs =(. I have this: <div id=header></div> <div id=body> <div
Again, I have got below code in VbScript, can you please suggest what will
Me again... I have an XML File that contains different categories which I would
Again in problem Actually I have following jsp code in which I have few
Once again a question about the garbage collector in actionscript-3: If I have a
Hi Again Masters Of The Web :) Now, I have got a new stupid
I again need help by you, this time I struggle with covariance, contravariance, delegates
Hello again Stackoverflow people! Assume I have these words: smartphones, smartphone I want to

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.