• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form Validation for Chinese Words

#1
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/]'
                       )
                   );
Reply


Messages In This Thread
Form Validation for Chinese Words - by IvanK - 07-03-2016, 06:57 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.