Lets say I have the input value:
var input_value = "** foo ** bar **";
Then I run this:
input_value = input_value.replace(/(\*\*)([\S\s.]+)(\*\*)/g,replacer_markup);
function replacer_markup(match, p1, p2, p3, offset, string) {
var pre = '';
var post = '';
if (p1 == '**')
{
pre = '<b>';
post = '</b>';
}
return pre+p2+post
}
It will give me:
foo ** bar
But instead I want to have:
foo bar **
I want to have the smallest possible result. How can I achieve this?
Sorry for any spelling mistakes, I'm not a native speaker. Thank you for your time.