Remove a long dash from a string in JavaScript?

后端 未结 4 782
梦如初夏
梦如初夏 2021-02-05 11:05

I\'ve come across an error in my web app that I\'m not sure how to fix.

Text boxes are sending me the long dash as part of their content (you know, the special long dash

4条回答
  •  旧时难觅i
    2021-02-05 11:22

    This code might help:

    text = text.replace(/\u2013|\u2014/g, "-");
    

    It replaces all (–) and (—) symbols with simple dashes (-).

    DEMO: http://jsfiddle.net/F953H/

提交回复
热议问题