Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Perl で言う特定の C プログラムから // および /**/ のすべてのコメントを削除できる正規表現はありますか?
複数行のプログラムを考えると、正規表現を使用してコメントを削除し、コメントアウトされていない部分を返す必要があります。
ありがとう。
で試してくださいRegexp::Common::comment:
Regexp::Common::comment
use Regexp::Common qw /comment/; while (<>) { s/($RE{comment}{C++})//; }
It's a FAQ:
How do I use a regular expression to strip C-style comments from a file?