Here is one example of what I need.
If I have some text like this one:
var string = "This is some test string for some my test.";
Then I have Regex like this one:
var patern = new RegExp("\\bsome\\b", 'gi');
and then line for replace:
var new_string = string.replace(patern,"replace_string");
This line above will replace all words "some" in string with "replace_string".
new_string = "This is replace_string test string for replace_string my test."
What I need is to limit it to replace it just once. Is that possible, and how?