Page 1 of 1
replace character in string
Posted: 14 Jan 2018, 21:27
by ilcergio
Hi, I have a variable with the text 1111 1111 3333 4444 and I want to pass it to another variable replacing the blanks by -
1111-1111-3333-4444
I thank you very much for the help
Re: replace character in string
Posted: 15 Jan 2018, 09:23
by francois
Hi,
an example :
Code: Select all
var re = / /g;
var chn_1 = "1111 1111 3333 4444";
var chn_2 = chn_1.replace(re,'-');
Console.print(chn_2)
Re: replace character in string
Posted: 15 Jan 2018, 16:14
by ilcergio
thank you very much francois
Re: replace character in string
Posted: 16 Jan 2018, 01:18
by MDLE46
Google translation.
Hello,
For beginners information: to learn javascipt, I recommend the site MDN web docs (from Moz://a).
link:
https://developer.mozilla.org/en-US/doc ... /@@replace
This case study is very well explained.
Cordially.
MDLE46
Re: replace character in string
Posted: 16 Jan 2018, 03:36
by MDLE46
Google translation
And the direct link for javascript methods :
https://developer.mozilla.org/en-US/docs/Web/JavaScript
Cordially.
MDLE46.