perl 去除一对()中的中文字符及括号本身

前端之家收集整理的这篇文章主要介绍了perl 去除一对()中的中文字符及括号本身前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

#perl 正则匹配中文字符

#gbk编码如下

 

#[\x80-\xFF]{2}

 

 

#!/usr/bin/perl -w
use strict;
use warnings;


#my $a = "aligned 中国(中国中)中国心(中国心中)426327399914 frames";
my $a = 'session 0: <enter>(<enter>) 啊(啊)<exit>(<exit>) 你好(你好)请(请)讲(讲)<exit>(<exit>)  (D:\hongmi\zhuxiaocheng\tbnr_phone_new_stream_onepass\bin\taobao\DVS+20121006151539406-44035.wav)';

  $a =~s/D:\\hongmi\\zhuxiaocheng\\tbnr_phone_new_stream_onepass\\bin\\taobao\\/ /; $a =~s/\.wav/ /; $a =~s/session 0://g; $a =~s/\<enter\>\(\<enter\>\)//g; $a =~s/\<exit\>\(\<exit\>\)//g; print "$a\n";   my  @chars = (split /\([\x80-\xFF]+?|[\x80-\xFF]+?\)/,$a);  foreach my $char (@chars) {   #$char =~s/D:\\hongmi\\zhuxiaocheng\\tbnr_phone_new_stream_onepass\\bin\\taobao\\//;   #$char =~s/session 0://g;   #$char =~s/\<enter\>\(\<enter\>\)//g;   #$char =~s/\<exit\>\(\<exit\>\)//g;   $char=~s/\s+//g;   $char=~s/\(/ ( /g;   $char=~s/\)/ ) /g;  print $char;  }

猜你在找的Perl相关文章