let's have string "the quick brown fox jumps on lazy dog."
i want use "the" left boundary , "dog" right boundary , replace in between space returns:
"the dog"
i sort of know how replace specified string substitute value, not know how replace in between boundaries. need sort of regular expression? appreciated.
the regex use (the).+?(dog)
the string operation this:
var str = "the quick brown fox jumps on lazy dog."; var result = str.replace(/(the).+?(dog)/, "$1 $2"); console.log(result);