免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5871 | 回复: 9
打印 上一主题 下一主题

苯苯的问,UltraEdit中,怎么利用正则表达式删除文件中的所有回车呢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-11 15:14 |只看该作者 |倒序浏览
10可用积分
这个删除控制字符的表达式这么写
删除文本文件中的所有回车呢

最佳答案

查看完整内容

[ 本帖最后由 smonkey0 于 2008-4-11 15:33 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-04-11 15:14 |只看该作者

回复 #4 dynamic516 的帖子

[code]
Symbol        Function
%        Matches the start of line - Indicates the search string must be at the beginning of a line but does not include any line terminator characters in the resulting string selected.
$        Matches the end of line - Indicates the search string must be at the end of line but does not include any line terminator characters in the resulting string selected.
?        Matches any single character except newline
*        Matches any number of occurrences of any character except newline
+        Matches one or more of the preceding character/expression.  At least one occurrence of the character must be found.
++        Matches the preceding character/expression zero or more times.
^b        Matches a page break
^p        Matches a newline (CR/LF) (paragraph) (DOS Files)
^r        Matches a newline (CR Only) (paragraph) (MAC Files)
^n        Matches a newline (LF Only) (paragraph) (UNIX Files)
^t        Matches a tab character
[ ]        Matches any single character, or range in the brackets
^{A^}^{B^}        Matches expression A OR B
^        Overrides the following regular expression character
^(...^)        Brackets or tags an expression to use in the replace command.  A regular expression may have up to 9 tagged expressions, numbered according to their order in the regular expression.The corresponding replacement expression is ^x, for x in the range 1-9.  Example: If ^(h*o^) ^(f*s^) matches "hello folks", ^2 ^1 would replace it with "folks hello".
Note - ^ refers to the character '^' NOT Control Key + value.

[/code]

[ 本帖最后由 smonkey0 于 2008-4-11 15:33 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2008-04-11 15:18 |只看该作者

回复 #1 dynamic516 的帖子

crtl+R    上面输入 ^p  下面哦为空.  全部替换

论坛徽章:
0
4 [报告]
发表于 2008-04-11 15:25 |只看该作者
书到用时方恨少,谢谢!

论坛徽章:
0
5 [报告]
发表于 2008-04-11 15:25 |只看该作者
特殊字符都有哪些pattern呀

论坛徽章:
0
6 [报告]
发表于 2008-04-11 15:32 |只看该作者
dos2unix

论坛徽章:
0
7 [报告]
发表于 2008-04-11 15:38 |只看该作者
不好意思
看错了
untraedit
俺从不用这东西
今生就从了vi

论坛徽章:
0
8 [报告]
发表于 2008-04-11 15:53 |只看该作者
1.不知道你要找的是不是正则表达式,偶有一个函数专门用来解决你这个问题的:
# trim space / tab at the end
sub trim {
        my $r = shift;
        $r =~ s/[      \n\r]+$//;
        return $r;
}

2.当然你也可以直接使用函数“chomp”;
3.Sample:
****************************************
use strict;
my $iline;
open(INFILE,"123.txt" ) or die"Open Failed!~";
open(OUTFILE,">456.txt" ) or die"Open Failed!~";
while(<INFILE>; )
{
  $iline=$_;
  $iline=trim($iline) ;
  #chomp $iline;
  print OUTFILE $iline;
}
close OUTFILE;
close INFILE;

# trim space / tab at the end
sub trim {
        my $r = shift;
        $r =~ s/[      \n\r]+$//;
        return $r;
}
***********************************

123.txt的内容你可以随意,
456.txt将是你要看到的结果,
可以自己测试一下,
如果要使用trim就直接使用此sample;
如果要使用chomp就注释掉使用trim函数的代码,并取消chomp的注释;
呵呵,一点浅见,有问题可以直接联系我,QQ:642977474

[ 本帖最后由 不死草 于 2008-4-11 15:56 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2008-04-14 09:00 |只看该作者
原帖由 churchmice 于 2008-4-11 15:38 发表
不好意思
看错了
untraedit
俺从不用这东西
今生就从了vi

建议试试 vim

论坛徽章:
0
10 [报告]
发表于 2008-04-14 18:45 |只看该作者
UltraEdit有一个选项, 大概是"起用Perl兼容正则式", 太老的版未提供.
这样就不用去记UE的那一套了:>
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP