[英]How to append backslash if pattern matches in javascript or jQuery
我必須檢查字符串是否包含某些特殊字符,如果包含特殊字符,請向其添加反斜杠。
var spChar=['%','^','!'];
如果字符串為"This contains % and ^ characters".
我要使其"This contains \\% and \\^ characters".
我不想遍歷所有角色。 反正我可以通過使用正則表達式來實現
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.