looking for a simple regular expression for this,
This is the input:
This is a sample text
eiwen34EDJ/VUFercsFIR/GRSnrr
Output:
eiwen34 ercs nrr
I want to remove 3 characters before and after '/'. i.e. In terms of my example, EDJ/VUF
and FIR/GRS
should be removed.
I was searched for many questions in here but didn't find the solution for it, please help me.
答案 0 :(得分:0)
您可以使用:
/[a-z]{3}\/[a-z]{3}/gi
这将检查斜杠前后的3个字符并替换为空格:
var string = 'eiwen34EDJ/VUFercsFIR/GRSnrr';
var newString = string.replace(/[a-z]{3}\/[a-z]{3}/gi, ' ');
console.log(newString);

答案 1 :(得分:0)
您还可以使用以下正则表达式替换,您不需要将其置于不区分大小写的情况下。
/[a-z]{3}\/[a-z]{3}/gi