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.<br><br><div class="gmail_quote">On Tue, Sep 15, 2009 at 1:00 PM, Anand Balachandran Pillai <span dir="ltr"><<a href="mailto:abpillai@gmail.com">abpillai@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br><div class="gmail_quote"><div class="im">On Tue, Sep 15, 2009 at 11:38 AM, Sampath Girish <span dir="ltr"><<a href="mailto:girishmsampath@gmail.com" target="_blank">girishmsampath@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"><div><br><br>Hi all,<div> 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. </div>
</div></div></blockquote></div><div><br>Did not understand what you meant by inbuilt validate function. There is nothing like that in Python.<br><br>>>> s='Python'<br>>>> s.validate<br>Traceback (most recent call last):<br>
File "<stdin>", line 1, in <module><br>AttributeError: 'str' object has no attribute 'validate'<br>>>> validate<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>
NameError: name 'validate' is not defined<br><br> </div><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote">
<div>
<div> </div>
</div><div>For e.g., Name: <font><b>Python</b></font><font><b><span style="background-color: rgb(255, 255, 255);">_</span></b></font><font color="#ff0000"><b><font color="#000000">India.</font></b> </font>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.</div>
</div></blockquote></div><div><br> Use a regular expression. For example, the following does the job for <br> matching a string with space in between 2 words.<br>>>> import re<br>>>> r=re.compile(r'\w+\s+\w+', re.IGNORECASE|re.LOCALE)<br>
>>> r.match('PythonIndia')<br>>>> r.match('Python India')<br><_sre.SRE_Match object at 0x7f0d17909168<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">
<div class="gmail_quote"><div>
<div><br></div><div>Thanks in advance,</div><div>Sampath Girish M</div>
</div></div><br>
<br></div>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><font color="#888888">--Anand<br><br><br><br>
</font><br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br>