删除只有数字空格和.的行-笨方法

tt posted @ 2007年10月29日 05:19 in 正则表达式 , 3151 阅读

在从网页上复制代码时,总是带着行号,这令人烦恼,不能直接拿过来运行,修改很是麻烦,于是乎,想一个简单点的方法进行修改-用正则表达式。

如下面的这些行,复制出来是数字单独一行,并且其前面带有空格多个

  1. PROJECT (Main)
  2.  
  3. FIND_PACKAGE(VTK REQUIRED)
  4. IF(NOT VTK_USE_RENDERING)
  5.   MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
  6. ENDIF(NOT VTK_USE_RENDERING)
  7. INCLUDE(${VTK_USE_FILE})
  8.  
  9. ADD_EXECUTABLE(main cut_sphere.cxx)
  10. TARGET_LINK_LIBRARIES(main vtkRendering)

我所采用的处理方法是,在vim的视图环境下,输入命令:

    :%s /[ ]*[0-9]*\.$\n//g

将一多个空格加多个数字,然后加一个点和换行符的字符串替换成空。
这就将所有空格加数字的行都清空了,以后从网页上面复制代码就可以很容易修改成自己需要的形式了。

 

 

 
Avatar_small
lyanry 说:
2007年11月03日 04:52 写blog时,把代码编辑器上的行号选项不选便是。
Avatar_small
jnanabhumiap.in 说:
2024年1月24日 23:44

JNANABHUMI AP provides a CBSE syllabus for all classes for the academic year 2024 has been designed as per the guidelines of the CBSE Board. The syllabus offers a conceptual background and lays the groundwork for the Class 10 Board exams. jnanabhumiap.in By visiting the page, students will find the downloadable pdf of the reduced CBSE 10th Syllabus along with the deleted portion of the syllabus for each subject. So, students are advised to prepare for the exam, as per the syllabus mentioned here.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter