title: Javascript: test regex and assign to variable if it matches in one line
body: <p>To test if a regex matches and assign it to a variable if it does, or assign it to some default value if it doesn't,
  I am currently doing the following:</p>
  
  <pre><code>var test = someString.match(/some_regex/gi);
  var result = (test) ? test[0] : 'default_value';
  </code></pre>
  
  <p>I was wondering if there is any way to do the same thing in JS with one line of code.</p>
  
  <p>Clarification:
  I am not trying to make my code smaller, but rather make it cleaner in places where I am defining a number of variables like so:</p>
  
  <pre><code>var foo = 'bar',
      foo2 = 'bar2',
      foo_regex = %I want just one line here to test and assign a regex evaluation result%
  </code></pre>