title: Capturing whitespace separating a group and an optional group
body: <p>I'm trying to implement a regex with the following task.
  A string contains a state name. At the end of the State name, optional parentheses may contain additional informations.
  Examples of valid strings:</p>
  <ul>
  <li>New York, US</li>
  <li>California, United States of America (USA)</li>
  <li>Massachusetts, United States of America(USA)</li>
  </ul>
  <p>Between the State name and the first parenthesis, a space may be present. The regex should extract the State name, dropping the optional content, as well as the space separating the State name and the optional content.
  At the moment I am using the following regex:</p>
  <pre><code>(?P&lt;country&gt;[A-Za-z ,]+)(?: {0,1})(?=[(])?(?:[(]\w*[)])?
  </code></pre>
  <p>Unfortunately, however, due to the greedyness of <code>(?: {0,1})(?=[(])?</code> the whitespace separating the State name and the optional content never gets captured, as shown in this <a href="https://regex101.com/r/i15dCj/1" rel="nofollow noreferrer">regex101</a>.
  The desired result would be <code>New York, US</code>, <code>California, United States of America</code>, and <code>Massachusetts, United States of America</code>.</p>
  <p>Any suggestion?</p>