How do I replace a string in a long string like below using regex (JS) please?
My string could be one of the following:
str = "this may have bgskin-akb4c hello how";
or
str = "have bgskin-a2b3c hello";
or
str = "bgskin-xyz2 hello";
or
str = "bgskin-bbc";
in the above string I would like to replace the 2nd part of the word (ex: -akb4c, -xyz2) starting with “bgskin” with a new string value, ex: “have bgskin-a2b3c hello” becomes “have bgskin-newstr hello”
Appreciate your help on this.
Many thanks,
L
In Javascript