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.
我已将 C/C++ 程序文件读入数组,现在我想从数组中删除所有注释C或C++样式,包括multilinecommnts。如何使用数组来做到这一点。
C
C++
multiline
这就是我将文件读入数组的方式。
open( FILE, $fname ) or die "Can't open $fname: $!"; my @lines = <FILE>; close(FILE);
It's explain in perlfaq6:How-do-I-use-a-regular-expression-to-strip-C-style-comments-from-a-file
请参考Mastering Regular Expression 3rd chapter 6,您将获得最佳解决方案。
Mastering Regular Expression 3rd chapter 6