There is a way to make Regexps work with accents and other characters
(including chinese ones) if we use some Regexp's special characters:

\w      Any word character (letter, number, underscore)
\W      Any non-word character

What we want our regexp to catch in this case is: "word_character AND
NOT number AND NOT underscore".

Regexp does not support ANDs, but it support ORs ([]) and NOTs ([^]).
We can translate the same sentence above as: "NOT (NOT word_character
OR number OR underscore)".

Which we can translate to regexp as: /[^\W\d\_]/

It actually works on Ruby 1.8.6 and you can check on Rubular:
http://rubular.com/regexes/5550

The only problem is that it does not check for uppercase or lowercase
characters, so this won't help in the underscore inflector.
But since you have to change another regexps this may help you in a
way that it works for more cases and it would be also faster then
using unicode character classes (which might actually be the only way
to solve the underscore case).

Regards,

--
José Valim
http://josevalim.blogspot.com/
http://www.pagestacker.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to