Regular expression not working in pywinauto unless I give full text
<p>Here is the code snippet that I am using:</p>

<pre><code>browserWin = application.Application()
browserWin.Start(&lt;FirefoxPath&gt;)
# This starts the Firefox browser. 
browserWin.Window_(title_re="\.* Firefox \.*")
</code></pre>

<p>If I use the expression: ".* Mozilla Firefox Start Page .*", it works. However, if I only use a partial text, it doesn't work. </p>

<p>What am I doing wrong here?</p>

<p>See this excerpt from the pywinauto source code:</p>

<pre><code>title_regex = re.compile(title_re)
def _title_match(w):
    t = handleprops.text(w)
    if t is not None:
        return title_regex.match(t)
    return False
</code></pre>

<p>The <code>return title_regex.match(t)</code> line means that the regex is passed to the <a href="https://docs.python.org/2/library/re.html#re.match" rel="nofollow"><code>re.match</code></a> method, so, the regex pattern is anchored at the string start.</p>

<p>To match for a partial match, you need to start the pattern with <code>.*</code>: <code>".* FireFox "</code>.</p>

python regex pywinauto