Regex matches only one string. Need it to match two
<p>I have the following regex</p>

<pre><code>^(.+?)(\s+engine$|\s+ROW_FORMAT)
</code></pre>

<p>with ignore case enabled.</p>

<p>The problem with this is, it matches either "engine" or "row_format" and doesn't match both (as shown in the <a href="https://regex101.com/r/qC3tB7/3" rel="nofollow">last example</a>). What am I missing here?</p>

<pre><code>In [17]: st = 'this is my engine and row_format'
In [18]: match = re.match('^(.+?)(\s+engine$|\s+ROW_FORMAT)', st, re.I)

In [19]: match
Out[19]: &lt;_sre.SRE_Match at 0x26c5030&gt;

In [20]: match.group(1)
Out[20]: 'this is my'

In [21]: st = 'this is my row_format and engine'

In [22]: match = re.match('^(.+?)(\s+engine$|\s+ROW_FORMAT)', st, re.I)

In [23]: match.group(1)
Out[23]: 'this is my'

In [24]: match.group(2)
Out[24]: ' row_format'

In [25]: match.group(3)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
&lt;ipython-input-25-da7df187e689&gt; in &lt;module&gt;()
----&gt; 1 match.group(3)

IndexError: no such group
</code></pre>

<p>add the special character <code>+</code>; this <a href="https://docs.python.org/3/library/re.html#regular-expression-syntax" rel="nofollow">causes the resulting RE to match 1 or more repetitions of the preceding RE</a></p>

<pre><code>^(.+?)(\s+engine$|\s+ROW_FORMAT)+
</code></pre>

python regex