---
title: "怎样用正则表达式匹配汉字 (perl)"
author: "jedy"
date: "2005-11-30T03:25:00Z"
tags: []
slug: "perl"
draft: false
lastmod: "2005-11-30T03:25:00Z"
id: 304776
url: "https://jedy.iteye.com/blog/304776"
---

转成unicode以后用property匹配，例（设输入输出编码为gb2312、gbk或gb18030）：

use Encode;  
$\_="abc你好wert";  
$a=decode('cp936',$\_);  
($x)=($a=~m/(\\p{Han}+)/);  
print encode('cp936',$x),"\\n";