You shouldn't be asking questions about using Python on python-dev -- this list is for development of Python.<br><br>Your problem is easily explained however: the second argument to p.findall() should be an offset, not a flag set. (You are confusing re.findall() and p.findall().)<br>
<br>--Guido<br><br><div class="gmail_quote">On Fri, May 21, 2010 at 4:32 PM, Lu, Hongchao (UI Health Care) <span dir="ltr"><<a href="mailto:luhon@healthcare.uiowa.edu">luhon@healthcare.uiowa.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">Hi All,</font></span><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2"> I am working on a script to use re.findall,</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">But the result seems wield.</font></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">--------------------------------------------------------------------</font></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">import re</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">p=re.compile("\S+",re.M)</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">pirfile="""</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;mm9|</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;petMar1|</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;cavPor3|</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;mm9|</font></span><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">:</font></span><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">"""</font></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">for m in p.findall(pirfile,re.M):</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2"> print m</font></span><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">Results:</font></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">|</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;petMar1|</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;cavPor3|</font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">>DL;mm9|</font></span><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">The first result is missing</font></span><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2"> some charact</font></span><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">e</font></span><span lang="en-us"></span><span lang="en-us"><font face="Arial" size="2">rs, Could you explain why? Any wrong with the script?</font></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">I tried Python2.4/2.6/2.7, the result is same.</font></span></p>
<br>
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">Thank you.</font></span></p>
<br><font color="#888888">
<p dir="LTR"><span lang="en-us"><font face="Arial" size="2">Hongchao Lu</font></span><span lang="en-us"></span><span lang="en-us"></span></p>
<p dir="LTR"><span lang="en-us"></span><span lang="en-us"></span></p>
</font></div>
<br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">http://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>