2020-12-22

JavaScript - Regex replace with matches

let str = 'abc def SOMETHING_TO_LOOK_FOR 12';

str = str.replace(

    /(.*)SOMETHING_TO_LOOK_FOR ([0-9]{1,})(.*)/

    , "$1 ANY_OTHER_TEXT $2 $3"

);

console.log(str);


No comments:

Post a Comment