[英]Replace a backslash comma to double backslash comma
How do I change replace a "\\,"
to "\\\\,"
? 如何更改将"\\,"
替换为"\\\\,"
? So that, the string OU=b\\,aditi,DC=zeus2,DC=com
becomes OU=b\\\\,aditi,DC=zeus2,DC=com
?? 这样,字符串OU=b\\,aditi,DC=zeus2,DC=com
变为OU=b\\\\,aditi,DC=zeus2,DC=com
?
I need some javascript solution, regex or replace function will do. 我需要一些JavaScript解决方案,可以使用正则表达式或替换功能。
(?=\\,)
Try this.Replace by \\
.See demo. 试试看。用\\
代替。请参阅演示。
https://regex101.com/r/pG1kU1/25 https://regex101.com/r/pG1kU1/25
var re = /(?=\\,)/gm;
var str = 'OU=b\,aditi,DC=zeus2,DC=com';
var subst = '\\';
var result = str.replace(re, subst);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.