function helpLinkConvert(str, p1, offset, s) {
return "<a href=\"look.php?word="
+encodeURIComponent(p1)+"\">"+p1+"</a>";
}
var message = "(look: this) is a (look: stackoverflow) question";
message = message .replace(/\(look: (.{1,80})\)/, helpLinkConvert);
This is what I want to do,
Before:
(look: this) is a (look: stackoverflow) question.
After:
this is a stackoverflow question
When there is only one matched string, it's working but in other cases It's not working properly,
How can I do that? Thanks.