Remove a long dash from a string in JavaScript?

后端 未结 4 689
梦如初夏
梦如初夏 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条回答
  •  礼貌的吻别
    2021-02-05 11:35

    That character is call an Em Dash. You can replace it like so:

    str.replace('\u2014', '');​​​​​​​​​​
    

    Here is an example Fiddle: http://jsfiddle.net/x67Ph/

    The \u2014 is called a unicode escape sequence. These allow to to specify a unicode character by its code. 2014 happens to be the Em Dash.

提交回复
热议问题