Model rules

Hi,

I’m trying to accept accents on this field but I can’t find the correct parameter to inform on my rules

test 1

array(‘title’, ‘match’, ‘pattern’=>’/^[a-zá-úA-ZÁ-Ú0-9 ]+$/’, ‘message’=>‘Title only can contain letters and numbers.’),

test 2

array(‘title’, ‘match’, ‘pattern’=>’/^[a-zA-Zá-úÁ-Ú0-9 ]+$/’, ‘message’=>‘Title only can contain letters and numbers.’),

test 3

array(‘title’, ‘match’, ‘pattern’=>’/^[a-zA-Z0-9éúíóáÉÚÍÓÁèùìòàÈÙÌÒÀõãñÕÃÑêûîôâÊÛÎÔÂëÿüïöäËYÜÏÖÄ ]+$/’, ‘message’=>‘Title only can contain letters and numbers.’),

Always get the error message defined.

Dude, to resolve it, you’ll need to use a unicode expression like this:




/^[a-z\u00C0-\u00ff A-Z]+$/




You can also try the u modifier for UTF-8 safe regex:

http://de.php.net/manual/en/reference.pcre.pattern.modifiers.php

So try something like:


array('title','match','pattern'=>'/[áóú]+/u'),

only errors… the 2 responses!

I’ve lent my crystal ball to a friend today, so i’m sorry, but maybe you could show us the errors. :)

Sorry dude.

The erros are

Case 1 using ‘/^[a-z\u00C0-\u00ff A-Z]+$/’

PHP Error

Description

preg_match() [<a href=‘function.preg-match’>function.preg-match</a>]: Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 6

Case 2 using ‘/[áóú]+/u’

PHP Error

Description

preg_match() [<a href=‘function.preg-match’>function.preg-match</a>]: Compilation failed: invalid UTF-8 string at offset 2

I tried other combinations using the examples you gave me but none works.

Maybe this will help: http:// www.regular-expressions.info /unicode.html