Finding particular column value via regex
<p>I have a txt file containing multiple rows as below. </p>

<pre><code>56.0000         3       1
62.0000         3       1
74.0000         3       1
78.0000         3       1
82.0000         3       1
86.0000         3       1
90.0000         3       1
94.0000         3       1
98.0000         3       1
102.0000        3       1
106.0000        3       1
110.0000        3       0
116.0000        3       1
120.0000        3       1
</code></pre>

<p>Now I am looking for the row which has '0' in the third column . </p>

<p>I am using python regex package. What I have tried is <code>re.match("(.*)\s+(0-9)\s+(1)",line)</code> but of no help.. </p>

<p>What should be the regular expression pattern I should be looking for?</p>

<p>You probably don't need a regex for this. You can <em>strip</em> trailing whitespaces from the right side of the line and then check the last character:</p>

<pre><code>if line.rstrip()[-1] == "0": # since your last column only contains 0 or 1
   ...
</code></pre>

python regex