如何将短划线 (-) 的所有实例替换为字符串中的正斜杠 (/)

How do I replace all instances of a dash (-) with a foward slash (/) in a string

本文关键字:字符串 替换 实例      更新时间:2023-09-26

我需要你的帮助,

如何用字符串中的正斜杠/替换破折号-的所有实例

var x = "03-04-2014"

转换后:

var x = "03/04/2014"

with string.replace

x = x.replace(/'-/g, '/')

或拆分

x.split('-').join('/')