Regex test and store result in javascript
<p>In ruby, I often use something like this:</p>

<pre><code>if "my string123" =~ /string(\d+)/
  puts "I got #{$1}"
end
</code></pre>

<p>How would I do something similar in javascript?  Currently, I've been doing this but it feels dirty.</p>

<pre><code>m = "my string123".match(/string(\d+)/)
if (m)
  puts "I got " + m[1]
</code></pre>

<p>Perhaps I should just live with this, but thought I'd ask if there was a syntax subtelty I was missing.  Thanks!</p>
