01 May 2017

JavaScript: Replace & Replace All & Replace Regex

Replace
JavaScript 2017
var a = 1,999,999.00 ;

//Replace
var b = a.replace(',' , '');
Output: 1999,999.00

//Replace ALL
while (a.indexOf(',') !== -1)
{
    b = a.replace(',' , '');
}
Output: 1999999.00

//Replace ALL + Regex
'Ja va Scri pt'.replace(/\s/g, '')
Output: JavaScript

0 nhận xét:

Post a Comment

 

BACK TO TOP

Xuống cuối trang