在以下文字中:
text\n\nWhy';
Run Code Online (Sandbox Code Playgroud)
我试图摆脱\(包括符号)后的所有内容,以便我的输出将是:text
我该怎么做?尝试:
var s = 'text\n\nWhy';
s = s.substring(0, s.indexOf('\'));
console.log (s)
Run Code Online (Sandbox Code Playgroud)
\n是换行符的转义字符.您需要搜索该"字符".
var s = 'text\n\nWhy';
s = s.substring(0, s.indexOf('\n'));
console.log (s)Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
124 次 |
| 最近记录: |