删除JavaScript正则表达式中“/ *”和“* /”之间的所有内容?

时间:2014-04-01 22:03:51

标签: javascript regex

如何删除JavaScript中字符串中/ *和* /(包括这些字符)之间的所有文本?谢谢!

1 个答案:

答案 0 :(得分:5)

1。你的正则表达式是

/\/\*.*?\*\//g

2。进行替换的JS代码是:

your_str = your_str.replace(/\/\*.*?\*\//g, '');

3。以下是正则表达式的解释:

Match the character "/" literally
Match the character "*" literally
Match any single character that is not a line break character
   Between zero and unlimited times, as few times as possible, expanding as needed (lazy)
Match the character "*" literally
Match the character "/" literally