CodeIgniter Forums
Form Validation for Chinese Words - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Form Validation for Chinese Words (/showthread.php?tid=65627)



Form Validation for Chinese Words - IvanK - 07-03-2016

I am using library of Form Validation in CodeIgniter.

Below config try to include all Number, English words, Chinese words and space. But it's not work.
Code:
$config = array(
               array(
                      'field' => 'keywords',
                      'label' => 'keywords',
                      'rules' => 'regex_match[/[a-zA-Z0-9 \u4e00-\u9fa5]+$/]'
                   )
               );

However, if I deduce '\u4e00-\u9fa5', it's work for English words.
Code:
$config = array(
                   array(
                          'field' => 'keywords',
                          'label' => 'keywords',
                          'rules' => 'regex_match[/[a-zA-Z0-9 ]+$/]'
                       )
                   );



Somebody tell me that 'uxxxx' is not work in PCRE.  They suggest me that "/\A[a-zA-Z0-9\s\p{Han}]+\z/".

I test "/\A[a-zA-Z0-9\s\p{Han}]+\z/" in online test website https://regex101.com/r/bC2iK2/1.  It's work. 
However, it is not work in my website.
Code:
$config = array(
                   array(
                          'field' => 'keywords',
                          'label' => 'keywords',
                          'rules' => 'regex_match[/\A[a-zA-Z0-9\s\p{Han}]+\z/]'
                       )
                   );