Regular expressions for accents like ó character in python
i want to restrict to user to not enter accents character. si i need to make an Regular expressions for accents like ó character -- http://mail.python.org/mailman/listinfo/python-list
Regular expression
Hi All, here i have on textbox in which i want to restrict the user to not enter the 'acent character' like ( é ) i wrote the program import re value="this is Praveen" #value = 'riché gerry' if(re.search(r"^[A-Za-z0-9]*$",value)): print "Not allowed accent character" else: print "Valid" output : sys:1: DeprecationWarning: Non-ASCII character '\xc3' in file regu1.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details Valid when i make comment #value="this is Praveen" and released comment value = 'riché gerry' but still i am getting same output even it have accent character. -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expression
On Jun 20, 10:58 am, Soltys <[EMAIL PROTECTED]> wrote: > Hi, > Your post is not about re, but about encoding, next time > be more careful when choosing topic for your post! > Did you check what pep0263 says about encoding? > One of the first thins it says is: > > "(...) > Defining the Encoding > Python will default to ASCII as standard encoding if no other > encoding hints are given. > (...)" > > So when you're using non ASCII characters you should always > specify encoding. Here again, read pep0263 for how this can > be done, especially section Defining Encoding, where there > are multiple ways of doing that. > > Sallu pisze: > > > > > Hi All, > > here i have on textbox in which i want to restrict the user to not > > enter the 'acent character' like ( é ) > > i wrote the program > > > import re > > value="this is Praveen" > > #value = 'riché gerry' > > if(re.search(r"^[A-Za-z0-9]*$",value)): > > print "Not allowed accent character" > > else: > > print "Valid" > > > output : > > > sys:1: DeprecationWarning: Non-ASCII character '\xc3' in file regu1.py > > on line 3, but no encoding declared; > > seehttp://www.python.org/peps/pep-0263.html > > for details > > Valid > > > when i make comment #value="this is Praveen" and released comment > > value = 'riché gerry' > > but still i am getting same output even it have accent character. > > -- > Soltys > > "Free software is a matter of liberty not price" I am sorry sotys..actually i am very much new to python.. import re import os, sys string = 'riché' print string def strip_accents(string): import unicodedata return unicodedata.normalize('NFKD', unicode(string)).encode('ASCII', 'ignore') msg=strip_accents(string) print msg Output : sys:1: DeprecationWarning: Non-ASCII character '\xc3' in file regu.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details riché Traceback (most recent call last): File "regu.py", line 13, in ? msg=strip_accents(string) File "regu.py", line 10, in strip_accents return unicodedata.normalize('NFKD', unicode(string)).encode('ASCII', 'ignore') UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: ordinal not in range(128) -- http://mail.python.org/mailman/listinfo/python-list
Accent character problem
Hi all and one i wrote this script, working fine without fail( just run it) import re value='This is Praveen' print value #value = 'riché gerry' #words=str(value.split()).strip('[]').replace(', ', '') ( here i tried to convert in to list and then back to string) #print words richre=re.compile(r'[a-zA-Z0-9]') if(richre.match(value)): print "Valid" else: print "Not allowed special characters" Output 1: (Fair) This is Praveen Valid but when i change the value like value='éhis is Praveen' then Output 2:(Fair) éhis is Praveen Not allowed special characters (because i wanted to check out the ascent(é) character so its working fine no issue) but when i give ascent(é) character in middle like value='This és Praveen' Output 3:(not fair) This és Praveen Valid even it have ascent character it should display message "Not allowed special characters" Please help me out. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Email Validation with domain
Hi All, import re msg=raw_input('Enter the email : ') def validateEmail(email): #if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9] {1,3})(\\]?)$", email) != None: if re.match("^([EMAIL PROTECTED])@((?:[-a-z0-9]+\.)+[a-z]{2,})$", email) != None: print 'Valis' else: print 'not' validateEmail(msg) i wrote a script above it works fine but it does not check for valid domain like .com .org .in how to validate with domain -- http://mail.python.org/mailman/listinfo/python-list
Re: Email Validation with domain
On Jul 2, 6:25 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Sallu <[EMAIL PROTECTED]> writes: > > validateEmail(msg) i wrote a script above it works fine > > Actually, no. It rejects a great many email addresses that are valid. > > > but it does not check for valid domain like .com .org .in how to > > validate with domain > > To validate a domain for delivery of email, check with the DNS by > requesting the A or MX record for that domain. > > To validate an email address, check with the mail server for that > domain by sending a message to the address. > > Neither of them should be "validated" by a regular expression. > > Please refer to RFC 3696 http://www.ietf.org/rfc/rfc3696.txt> > described as "Recommended techniques for applications checking or > manipulating domain and other internet names". > > -- > \ “Pinky, are you pondering what I'm pondering?” “Wuh, I think | > `\ so, Brain, but wouldn't anything lose its flavor on the bedpost | > _o__) overnight?” —_Pinky and The Brain_ | > Ben Finney Thank you to all of you and clearing my idea.. -- http://mail.python.org/mailman/listinfo/python-list
Validation in plone
Hi all and one, How to do server side validation in plone? please help me its very urgent. i created a validator.py file where i wrote a script for 'special character are not allowed' and calling that script in movie.py its working fine by validators = ('splcharvalid',), and when i wrote another script for email validation and want to call in same field like validators = ('emailvalid',), and i am calling like this validators = ('splcharvalid',),('emailvalid',), but its not working even i wrote like this too validators = ('splcharvalid','emailvalid',), but its too not working.. could you please help mr to resolve this problem or may tell me another way to do validation in plone.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with parsing a list
On Dec 17, 4:23 am, "thunderf...@gmail.com" wrote: > not as slick as Emile's (didn't think about using strip() ), but > seemingly functional: > > data = ['key1: data1','key2: data2','key3: data3',' key4: ',' > \tdata4.1',' \tdata4.2',' \tdata4.3','key5: data5'] > result = {} > > for item in data: > if item.endswith(': '): > currkey = item[:-2] > result[currkey] = [] > elif item.startswith(' \t'): > result[currkey].append(item[2:]) > else: > key, val = item.split(': ') > result[key] = val > > print 'data = %s' % data > print 'result = %s' % result > > > > data = ['key1: data1', 'key2: data2', 'key3: data3', ' key4: ', ' > \tdata4.1', ' \tdata4.2', ' \tdata4.3', 'key5: data5'] > result = {'key3': 'data3', 'key2': 'data2', 'key1': 'data1', 'key5': > 'data5', ' key4': ['data4.1', 'data4.2', 'data4.3']} > > > > Hi i tried with thunderfoot code error: Traceback (most recent call last): File "", line 8, in ? ValueError: need more than 1 value to unpack -- http://mail.python.org/mailman/listinfo/python-list