title: Regex pattern returns null for variable as pattern
body: <p>I am reading regex pattern from a .txt file and passing it as a variable and using it to search in a very big text file. However, variable passing in regex search didnt work. My code snippet is</p>
  <pre><code>with open(r&quot;C:\Desktop\list_pattern.txt&quot;, &quot;r&quot;) as file1:
    for pattern in file1:
        with open(r'C:\Desktop\log.txt',&quot;r&quot;) as my_file:
            for lines in my_file:
                k=re.search('{}'.format(pattern), lines)   # I even tried re.search(pattern, lines)            
                if k!=None:
                    print(&quot;k is&quot;,k)
  
  </code></pre>
  <p>For example, the first lne in list_pattern.txt is &quot;Battery Low&quot; and it gives 0 match in log.txt. However, if i replace the code line with <code>k=re.search('Battery Low', lines)</code>, it gives 12 match. Any idea what may be wrong? I am using python 3.10.</p>