可能重複:
Regex to strip line comments from C#匹配正則表達式中的註釋(//註釋)引號外面
我完全被卡住這一點,我不擅長正則表達式。
Basicly我想匹配的文本塊註釋,比如這一個:
//Comment outside quotations string text = "//Comment inside quotations.."; //Another comment
我只想頂部和底部的評論相匹配,而不是中間的一個內部報價
我現在有意見的是:
//.*$
在整個行的末尾匹配註釋。
我希望這用於文本框中的語法突出顯示。
這可能嗎?
謝謝!奇蹟般有效! – user1944775
@ user1944775注意一點。這個正則表達式僅適用於換行註釋。 // CommentX in'string text =「// Comment quotations quotations ..」; // CommentX'將不匹配。 –