Re: [問題] 請問怎麼找出註解

看板RegExp (正規表示式 Regular Expression)作者 (阿樂)時間12年前 (2012/08/15 14:15), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《ccbruce (今、そこに いる僕)》之銘言: : 我是用.net的Regex的 : 現在想要寫一個可以刪掉所有C/C++ Style comment的程式 : 而且不可以刪掉包在双引號內的類似註解的字串 : 現在用的pattern為: : (?!")((//.*)|((?s)(/\*.*?\*/)))(?<!") : 雖然可以找出單行跟多行註解, 不過包在字串裡的類似註解的字串也一起被找出來了 : 請問有什麼解決的方法嗎? : 正常: : //comment : "aaa" //comment : /* : comment : */ : "aaa" /* : comment : */ : 異常: : "//not comment" : "/*not comment" 總算看懂了 編號一下 //comment1 "aaa" //comment2 /* comment3 */ "aaa" /* comment4 */ "//not comment5" "/*not comment6" (?<!")(//[^\n]+|/\*.*?\*/) 得 //comment1 //comment2 /* comment3 */ /* comment4 */ 是這個意思嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.248.18.139
文章代碼(AID): #1GApvpur (RegExp)
討論串 (同標題文章)
本文引述了以下文章的的內容:
以下文章回應了本文
完整討論串 (本文為第 2 之 3 篇):
文章代碼(AID): #1GApvpur (RegExp)