除掉代码中的行号

来源:互联网 发布:黄金行情分析软件 编辑:程序博客网 时间:2024/05/02 02:00
有时在网上看到很好一段代码,复制下来后,却无法使用,原因是:复制的时候连同行号一起复制了下来.

如果手动去除的话,行数很多会累死人啊,后来发现了一种方法来去掉行号,就是用正则表达式.

  1.   16. function Browser() {  
  2.   17.   var ua, s, i;  
  3.   18.   this.isIE = false;  
  4.   19.   this.isNS = false;  
  5.   20.   this.isOP = false;  
  6.   21.   this.isSF = false;  
  7.   22.   ua = navigator.userAgent.toLowerCase();  
  8.   23.   s = "opera";  
  9.   24.   if ((i = ua.indexOf(s)) >= 0) {  
  10.   25.     this.isOP = true;return;  
  11.   26.   }  
  12.   27.   s = "msie";  



用Notepad2 或者 UltraEdit 等支持正则表达式查找的编辑器

使用:[0-9]+[.]%[ ^t]+[0-9]+[.] 来查找行号就可以了,然后替换就行了.