php 中文正則表示 regexp

網路上一堆錯的

條件

1.php

2.utf-8

3.中英文

4.空白 ,._-符號

 

參考自
http://www.cnblogs.com/seanxyh/archive/2013/04/03/2998596.html

 

$pattern ='/^[\x{4e00}-\x{9fa5}A-Za-z0-9 ,._-]+$/u';
$pattern ='/^[\x{4e00}-\x{9fa5}A-Za-z0-9 ,._-]+$/u';
$message = $this->input->post('message');
 
if(preg_match($pattern, $message, $hereArray)){

}

發佈留言