Regular expressions for accents like ó character in python

Discussion in 'Python' started by Sallu, Jun 19, 2008.

  1. Sallu

    Sallu Guest

    i want to restrict to user to not enter accents character. si i need
    to make an Regular expressions for accents like ó character
     
    Sallu, Jun 19, 2008
    #1
    1. Advertising

  2. En Thu, 19 Jun 2008 02:08:38 -0300, Sallu <>
    escribió:

    > i want to restrict to user to not enter accents character. si i need
    > to make an Regular expressions for accents like ó character


    You may enumerate all the allowed characters:

    py> allowed_re = re.compile(r"^[A-Za-z0-9 ]*$")
    py> input = "hello world"
    py> allowed_re.match(input)
    <_sre.SRE_Match object at 0x00A3C1E0>
    py> input = "código inválido"
    py> allowed_re.match(input)
    py> print allowed_re.match(input)
    None

    --
    Gabriel Genellina
     
    Gabriel Genellina, Jun 19, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas
    Replies:
    0
    Views:
    610
    Jay Douglas
    Aug 15, 2003
  2. Fabrice DELENTE

    python+ncurses: I can't display accents

    Fabrice DELENTE, Jan 26, 2007, in forum: Python
    Replies:
    14
    Views:
    790
    Thomas Dickey
    Jan 27, 2007
  3. An. Valula
    Replies:
    3
    Views:
    184
    Alan J. Flavell
    Oct 23, 2003
  4. Replies:
    6
    Views:
    163
    Brian McCauley
    Jun 8, 2007
  5. Noman Shapiro
    Replies:
    0
    Views:
    235
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page