I'm still new in regex and still learning. But struggle to achieve this one.
What I want from here is to change a specific number with this format:
(space)(number)(space) or (space)(number)(word)
This is my current code:
let initial = "Sample 50 This 500是是 50是 of 50是. Sample 450是是";
let regex = new RegExp("\\b50|\\b50\\D", "g");
let result = initial.replace(regex, "9");
console.log(result);
So from this string:
Sample 50 This 500是是 50是 of 50是. Sample 450是是
The result should be this one:
Sample 9 This 500是是 9是 of 9是. Sample 450是是
But my current result is this (500 also changed):
Sample 9 This 90是是 9是 of 9是. Sample 450是是
Is this possible? Thanks for the help.