我有这个:
Anchor, Island, Super Over, Power Play
我想要这个:
Anchor,Island,Super Over, Power Play
Power Play有两个spce
答案 0 :(得分:1)
这将用逗号替换逗号和单个空格。
> "Anchor, Island, Super Over, Power Play".replace(/,\s/g, ",")
'Anchor,Island,Super Over, Power Play'
OR
这将用空字符串替换逗号后的一个或多个空格。
> "Anchor, Island, Super Over, Power Play".replace(/,\s+/g, ",")
'Anchor,Island,Super Over,Power Play'