What you are looking for is called regular expressions. For more information, you can visit the site, for example: http://www.regular-expressions.info/
Please note that regular expressions are not JavaScript.
In your specific example:
string.replace(/abc.+xyz/,"abc"+newString+"xyz");
. means any character, and + means one or more occurrences.
If you have a few notes, try:
string.replace(/abc.+?xyz/g,"abc"+newString+"xyz");
g means total, and? this is a lazy quantifier, meaning that it will stop the next time xyz appears on the line.
source share