开发者

Flex: replace all spaces with comma

开发者 https://www.devze.com 2022-12-24 23:02 出处:网络
im new with regexp, so can i ask for some assistance Using string.replace function what code that can replace spaces with comma

im new with regexp, so can i ask for some assistance

Using string.replace function what code that can replace spaces with comma

Input:The quick brown fox jumps over t开发者_StackOverflowhe lazy dog. Output:The,quick,brown,fox,jumps,over,the,lazy dog.

Thanks


Like this:

str = str.replace(/ /g, ',');

Here's a better one which will replace all strings of whitespace:

str = str.replace(/\s+/g, ',');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号