• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regex_match and accented characters

#1
Hi,
I'm new member of this forum.
I use form_validation to validate a form.

I need to accept accented characters for inputs. 
To do it, I use a rule in my config array :
'rules' => array('required','regex_match[/^[\w\-\[email protected]]{1,30}$/]' ),

However, this regexp don't accept accented characters.
As a workaround, I can add accented characters , for exemple :
'rules' => array('required','regex_match[/^[\w\-\[email protected]àéèù]{1,30}$/]' ),

But I don't like this workaround.
How can I do ? What is the adequate regexp ?

Thanks a lot for your help
Reply

#2
You need to add u for unicode.
Code:
/^[\w\-\[email protected]]{1,30}$/u

Personally I use these two:

Code:
$config['error_alpha_numeric_spaces_dash'] = '/^[\w\s-_]+/u';
$config['error_alpha_numeric_spaces_dash_colon'] = '/^[\w\s:-_]+/u';


And use min_length[1] and max_length[30] instead of limiting the regular expression. So that I can re use it later.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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