[BangPypers] Fwd: How to validate a String with spaces using inbuilt validate function

Shashwat Anand anand.shashwat at gmail.com
Tue Sep 15 14:05:28 CEST 2009


Please be a little more precise as to what do you exactly mean by 'validat'
? What exactly do you want to achieve with it. Sample Input and desired
output will help.

On Tue, Sep 15, 2009 at 1:00 PM, Anand Balachandran Pillai <
abpillai at gmail.com> wrote:

>
>
> On Tue, Sep 15, 2009 at 11:38 AM, Sampath Girish <girishmsampath at 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 at python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>>
>
>
> --
> --Anand
>
>
>
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20090915/91832a05/attachment.htm>


More information about the BangPypers mailing list