Assuming all the URLs begin with https_imgur.com, this should find them all and replace them.
let text = `Some stuff here. https_imgur.com/WERTYU.jpg
Some more stuff.
https_imgur.com/DRTYSF.jpg blah blah`;
let result = text.replace(/https_imgur.com/w+.jpg/g, '<img src="$&">');
console.log(result);
$& 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 = /https://i.imgur.com/w+.jpg/g;
var subst = `<img width='340' src="$&">`;
$("article").html(postData.replace(regex, subst));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<article>
<p>Look at this.</p>