On Tue, Sep 15, 2009 at 11:38 AM, Sampath Girish <girishmsamp...@gmail.com>wrote:
> > > Hi all, Can anyone please tell me how to validate a String with > spaces provided in between using inbuilt validate function. Please give me a > solution for this. > Did not understand what you meant by inbuilt validate function. There is nothing like that in Python. >>> s='Python' >>> s.validate Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'validate' >>> validate Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'validate' is not defined > > For e.g., Name: *Python**_**India.* The '_ ' is the space. When i use > 'validate' function in entry field, it must be able to detect spaces and > text only and accept that. > Use a regular expression. For example, the following does the job for matching a string with space in between 2 words. >>> import re >>> r=re.compile(r'\w+\s+\w+', re.IGNORECASE|re.LOCALE) >>> r.match('PythonIndia') >>> r.match('Python India') <_sre.SRE_Match object at 0x7f0d17909168 > > Thanks in advance, > Sampath Girish M > > > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > http://mail.python.org/mailman/listinfo/bangpypers > > -- --Anand
_______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers