从* .cpp文件中删除标题注释块

时间:2013-11-06 21:43:14

标签: search replace comments

我现在正在尝试从很多* .cpp文件中删除方法标题注释。 我尝试了许多建议,但从未取得过成功。

cpp评论如下:

//-----------------------------------------------------------------------------
/*
* @brief  bla foo
* @param  some param
*/
//-----------------------------------------------------------------------------
void Class::Methode1(param) {
}

          // <-- extra newline should be removed too
//-----------------------------------------------------------------------------
/*
* @fn     thats a function
* @brief  bla foo
* @param  some param
* @return exit code 
*/
//-----------------------------------------------------------------------------
int Class::Methode2(param) {
}

我正在寻找一种简单的方法来删除标题,包括方法之间的一个额外换行符。带有“----”的行不总是具有相同数量的“ - ”。 文件采用unix文件格式。

欢迎使用每个命令,只要它在Linux中运行。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

很久以后,我找到了办法。

我使用了perl脚本:

  #!/usr/bin/perl -pi
  #multi-line in place substitute - subs.pl
  use strict;
  use warnings;

  BEGIN {undef $/;}

  s|//\-{77}.{1,2}/\*.{1,200}\*/.{1,2}//\-{77}||smg;