Flex: replace all spaces with comma

两盒软妹~` 提交于 2019-12-18 05:45:34

问题


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 the lazy dog. Output:The,quick,brown,fox,jumps,over,the,lazy dog.

Thanks


回答1:


Like this:

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

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

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


来源:https://stackoverflow.com/questions/2504863/flex-replace-all-spaces-with-comma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!