Regular expressions for accents like ó character in python

S

Sallu

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

Gabriel Genellina

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top