Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex Flex正则表达式多行注释_Regex_Visual Studio 2008_Bison_Lex_Flex Lexer - Fatal编程技术网

Regex Flex正则表达式多行注释

Regex Flex正则表达式多行注释,regex,visual-studio-2008,bison,lex,flex-lexer,Regex,Visual Studio 2008,Bison,Lex,Flex Lexer,有人能给我解释一下区别吗,我已经测试了两个多小时了 This regex \"(.|\n)*\" gets everything inside " " (along with the " "). This regex "//".*$ gets a single line comment(c). `But the regex \/\*(.|\n)*\*\/ doesn't get a multy line comment 相反,它变得太多了,我甚至不明白。有人能给我解释一下区别吗?[^“

有人能给我解释一下区别吗,我已经测试了两个多小时了

 This regex \"(.|\n)*\" gets everything inside " " (along with the " ").

 This regex "//".*$ gets a single line comment(c).

`But the regex \/\*(.|\n)*\*\/ doesn't get a multy line comment

相反,它变得太多了,我甚至不明白。有人能给我解释一下区别吗?[^“]也意味着除“是否可以写入[^*/]或它将*和/作为非连接字符”之外的所有内容。顺便说一下,我在VS2008上运行了所有这些(使用flex和bison)。我发现了一些在VS2008上不起作用的例子,所以如果有人知道一个解释regex的非常好的网站,请与我分享,因为我感觉自己迷失在迷宫中。谢谢你抽出时间

尝试使用下面的正则表达式获取注释部分以及注释的开始和结束块:

b = /\/\*(.)*(\n)?(.)*\*\/g
e、 g

希望这对你有帮助

此表达式适用于JS。我想你应该试试

"\/\*((.)*(\n)?)*(.)*\*\/"

谢谢你的回答。我从来没有用过像b=regeg或a.replace这样的词。无论如何,我尝试在我的代码上/\/*(..*(\n)?(..***\///g这个,它说“错误1错误PRJ0019:一个工具从“生成词法分析器…”Project3 Project3“regex返回了一个错误代码,在以前更新过,有一个错误。正确的是/\/*()*(\n)?()***\/t再次感谢您的宝贵时间。我尝试了所有的方法,唯一没有错误的是这个“\/*()*(\n)?()***\/”,但它什么也没做/我认为在评论中粘贴是删除了某些部分,对此我很抱歉。“\/\*()*(\n)?()****\/”在回答最后一行\/*()*(\n)?(.***\)中更新后,尝试此选项确实有效,但仅适用于1行/*注释*/它不支持多行注释。
"\/\*((.)*(\n)?)*(.)*\*\/"