On Oct 3, 2009, at 7:50 AM, mdipierro wrote:

> something like this?
>
> def MYVALIDATOR:
>    def __init__(self,error_message):
>          self.error_message=error_message
>    def __call__(self,value):
>          if not re.compile('^([a-zA-Z]*[ ]*[á]*[é]*[í]*[ó]*[ú]*)+

Why not:

>          if not re.compile('^([a-zA-Z áéíóú]*)+

Plus some others (like ñ). Plus their upper-case variants.

Isn't there a proper Unicode way to do this?

> $').match(value):
>               return (value,self.error_message)
>          else:
>               newvalue=''
>               for c in value:
>                     if c in 'áéíóú': new_values+=self.do_something(c)
>                     else: newvalue+=c.upper()
>              return (newvalue,None)
>    def do_something(self,c):
>         return {'á':"A'",'é':"E'",'í':"I'",'ó':"O'",'ú':"U'"}[c]
>
> requires=MYVALIDATOR()



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to