小编Don*_*ong的帖子

如何使用perl正则表达式检测阿拉伯语字符?

我正在解析一些html页面,需要检测里面的任何阿拉伯字符.试过各种正则表达式,但没有运气..

有谁知道这样做的工作方式?

谢谢


这是我正在处理的页面:http: //pastie.org/2509936

我的代码是:

#!/usr/bin/perl 
use LWP::UserAgent; 
@MyAgent::ISA = qw(LWP::UserAgent); 

# set inheritance 
$ua = LWP::UserAgent->new; 
$q = 'pastie.org/2509936';; 
$request = HTTP::Request->new('GET', $q); 
$response = $ua->request($request); 
if ($response->is_success) { 
    if ($response->content=~/[\p{Script=Arabic}]/g) { 
        print "found arabic"; 
    } else { 
        print "not found"; 
    } 
}
Run Code Online (Sandbox Code Playgroud)

regex perl utf-8 arabic

2
推荐指数
1
解决办法
1823
查看次数

标签 统计

arabic ×1

perl ×1

regex ×1

utf-8 ×1