Why isn't this regex matching a string with percentage symbol?
<p>I have a file which has the following input : </p>

<pre><code>xa%1bc
ba%1bc
.
.
</code></pre>

<p>and so on. I want to use <code>match</code> and <code>regex</code> to identify the lines which have <code>a%1b</code>in them. 
I am using </p>

<pre><code> import re
 p1 = re.compile(r'\ba%1b\b', flags=re.I)
 if re.match(p1,linefromfile):
    continue
</code></pre>

<p>It doesnt seem to detect the line with %1. What is the issue? Thanks</p>

<p>You can try</p>

<pre><code>if 'a%1b' in linefromfile:
</code></pre>

<p><strong>OR</strong></p>

<p>if you need regex</p>

<pre><code>if re.match('a%1b', linefromfile):
</code></pre>

python regex string match word-boundary