正则表达式查找 C 风格的块注释 [英] Regular expression to find C style block comments

查看:37
本文介绍了正则表达式查找 C 风格的块注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用正则表达式找到这种模式?

How to find this pattern using regex?

C 风格块注释

/* xxxxxxxxxxxx */

推荐答案

尝试使用

\/\*(\*(?!\/)|[^*])*\*\/

捕获单行和多行块注释.它搜索 /* 后跟任意数量之一:

to capture single line and multi-line block comments. It searches for /* followed by any number of either:

  • 一个*,后面没有/
  • 任何字符 except *
  • an * that is not followed by a /
  • any char except *

然后再次关闭 */.

这篇关于正则表达式查找 C 风格的块注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆