I would like to filter this string
Field Strength 3T
and make it
Field Strength: 3T
What javascript regex should I use? I need to remove the extra spaces, add :, and add 1 space
CodePudding user response:
Try this code:
const regex = /\s{2,}/g;
const str = "Field Strength 3T ";
console.log(str.trim().replace(regex, ": "));