Flex: replace all spaces with comma

前端 未结 1 1741
傲寒
傲寒 2020-12-18 23:58

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 jum

相关标签:
1条回答
  • 2020-12-19 00:16

    Like this:

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

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

    str = str.replace(/\s+/g, ',');
    
    0 讨论(0)
提交回复
热议问题