[英]Regular Expression for forward slash
有人可以在Javascript中提供一個正則表達式,該表達式允許除正斜杠(/)之外的所有內容
謝謝
您可以執行以下操作(假設您要刪除所有正斜杠“ /”):
var string = "/ I'm going to remove everything but this / cool / !@#!@123 `23";
string = string.replace(/\//g, '');
console.log(string); // I'm going to remove everything but this cool !@#!@123 `23
正則表達式為/\\//g
我們必須使用反斜杠(\\)來避免正斜杠
“ g”用於全局查找所有匹配項
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.