EN
TypeScript - change commas into dots
0
points
In this article, we would like to show you how to change commas into dots in TypeScript.
Quick solution:
let x: string = '0,5';
x = x.replace(/,/g, '.'); // 0.5
Practical example
In this example, we change the comma into a dot using regex.
let x: string = '0,5';
const expression: RegExp = /,/g;
const replacement: string = '.';
x = x.replace(expression, replacement);
console.log(x); // 0.5
Output:
0.5