regular expression with special chars

Posted by xRobot on Stack Overflow See other posts from Stack Overflow or by xRobot
Published on 2010-05-16T09:46:39Z Indexed on 2010/05/16 9:50 UTC
Read the original article Hit count: 183

Filed under:
|

I need a regular expression to validate string with one or more of these characters:

  • a-z
  • A-Z
  • '
  • àòèéùì
  • simple white space

FOR EXAMPLE these string are valide:

D' argon calabrò

maryòn l' Ancol

these string are NOT valide:

hello38239

my_house 

work [tab] with me

I tryed this:

re.match(r"^[a-zA-Z 'òàèéìù]+$", self.cleaned_data['title'].strip())

It seems to work in my python shell but in Django I get this error:

SyntaxError at /home/

("Non-ASCII character '\\xc3' ...

Why ?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-forms