regex - Locale sensitive character classes in regexp with validations? -


validates_format_of :first_name, :with => /\a\w+\z/ 

the validation doesn't pass if there non-english character in first name, mölläinen. changing rails locale doesn't help. how do culture/locale sensitive validation then?

if locale en, \w should map [a-za-z0-9_], if it's fi, should map [a-za-z0-9_äöåÄÖÅ] , on.

try /\a[[:alpha:]]+\z/. should locale aware, @ least in ruby 1.9.

but might want allow other characters too. anna-lena common name in germany, example.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -