Invalid syntax error in an `if` statement which I am unable to understand? : <p>I went line by line and came up to this error.</p>

<blockquote>
  <p>SyntaxError: invalid syntax</p>
</blockquote>

<p>In, the <code>emailRegex</code> gets highlighted</p>

<p><code>if cell.value and isinstance(cell.value, str) emailRegex.match(cell.value):</code></p>

<p>The complete code(python3.x)</p>

<pre><code>import re, openpyxl, os, sys
def sort_email_from_xl():
    loc = input("Please enter path of the file:")
    os.chdir(loc)
    file = input("Filename:")
    wb = openpyxl.load_workbook(file, use_iterators=True)
    sheet = input("Which Sheet do you want to email?\n")
    return sheet
    wb.get_sheet_by_name(sheet)
    ws = wb.get_sheet_by_name(sheet)
    emailRegex = re.compile(r".*?([a-zA-Z0-9\._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4}).*?")
    customeremails = []        #works fine till here in idle
for row in ws.iter_rows():
    for cell in row:
        if cell.value and isinstance(cell.value, str) emailRegex.match(cell.value):
            mail = emailRegex.match(cell.value)
            if mail:
                mail = mail.group(0) # use parentheses to call the function 
                cell.text = mail
                customeremails.append(mail)

print(customeremails)
</code></pre>

<p>Can someone point to a resource where I can read what exactly is going wrong? I have been trying to sort this function out for almost 12 hours now, with help from SO and reading through docs.</p>

<p>Is the code fine after current error?</p>

<p>Thanks</p>
