title: regex — matching without trailing characters
body: <p>I am attempting to match the following (these are all seperate strings):</p>
  
  <pre><code>'Los Angeles, CA'
  'New York, NY'
  'Williamsburg, Brooklyn, NY'
  </code></pre>
  
  <p>from the following strings:</p>
  
  <pre><code>'Los Angeles, CA 90001, USA'
  'New York, NY 10017, USA'
  'Williamsburg, Brooklyn, NY, USA'
  </code></pre>
  
  <p>I am using JavaScript. So far I have:</p>
  
  <pre><code>var re = /.+[A-Z]{2}( |,)/,
      location = '',  // Address string here
      substring = location.match(re)[0];  // Returns something like Williamsburg, Brooklyn, NY,
  </code></pre>
  
  <p>While this regex will match the string examples above, I am left with a trailing whitespace or a comma depending on the string. I can <code>slice()</code> the trailing character, but I was curious if this can be done within the regex itself. Is this possible?</p>