title: TypeError: Cannot read property '1' of null theFunction [Javascript]
body: <p>I have a piece of javascript code that is like this:</p>
  
  <pre><code>var regex = /&lt;img.*?src=['"](.*?)['"]/;
  var image = regex.exec(input.str)[1]; 
  </code></pre>
  
  <p>and it gets the error when there is nothing found, when the regex is executed.</p>
  
  <pre><code>TypeError: Cannot read property '1' of null theFunction (eval at &lt;anonymous&gt; (/var/task/index.js:52:23), &lt;anonymous&gt;:50:34) eval (eval at &lt;anonymous&gt; (/var/task/index.js:52:23), &lt;anonymous&gt;:68:20) Domain.&lt;anonymous&gt; (/var/task/index.js:53:5) Domain.run (domain.js:228:14) module.exports.handler (/var/task/index.js:51:5)
  </code></pre>
  
  <p>Is there a way to stop this error from happening?</p>