Languages
[Edit]
EN

TypeScript - change commas into dots

0 points
Created by:
Welsh
902

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
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join