Solution 1 :

Assuming all the URLs begin with, this should find them all and replace them.

let text = `Some stuff here.
Some more stuff. blah blah`;

let result = text.replace(/, '<img src="$&">');

$& in the replacement string gets replaced with the match for the regexp.

Solution 2 :

Consider the following example.

jQuery(function($) {
  var postData = $("article").html();
  var regex = /;
  var subst = `<img width='340' src="$&">`;
  $("article").html(postData.replace(regex, subst));
<script src=""></script>

  <p>Look at this.</p>
View post on
<p>Look at that.</p>
View post on
<div></div> </article>

You will have to examine the Source of the resulting Post. Then adjust your Selector properly.

Problem :

i need your help i have a list like this of urls

i need to change them to an html img tag like this

<img src="">
<img src="">

i tried to use regex but i can’t find a solution

my idea is adding prefix and suffix to img url


Comment posted by Barmar

There’s no need for a regexp. Just use string concatenation or a template literal.

Comment posted by Barmar

Or use

Comment posted by cine ebay

because these urls are in wordpress post and i can just use find and replace plugin with regex

Comment posted by Barmar

Well, that’s different. You said you had a list of urls, not a block of text containing urls somewhere in it.

Comment posted by cine ebay

yes maybe i didn’t explained verry well thanks

Comment posted by cine ebay

yes sir it is working in js code snippet

Comment posted by cine ebay

but in the replacement string i don’t know what to do

Comment posted by Barmar

Assign it back to the

Comment posted by

in this example you will understand what i mean

Comment posted by

Select the JavaScript flavor to get