title: Taking exception.stack prints correctly until attempting to parse the string in ReactJS
body: <p>I am working on a project where I am trying to parse an exception object which I retrieve from the exception object created in a catch, using <code>exception.stack</code>.</p>
  <p>Below is the code to parse the stacktrace</p>
  <pre><code>getLineNoFromStacktrace(stack)
      {
          console.log(&quot;The stack is&quot;);
          console.log(stack);
          const stackSplit = stack.split(/\r?\n/);
  
          console.log(stackSplit);
  
          console.log(&quot;Stack line 1: &quot;);
          console.log(stack);
  
          /*stack = stack.replace(&quot;http://&quot;);
          stack = stack.replace(&quot;https://&quot;);
          //Get the first colon (:), after this is the line number)*/
          const lineInfo = stack.substring(stack.indexOf(&quot;:&quot;)+1);
  
          console.log(&quot;Line info: &quot; + lineInfo);
          //Now what we have left, the colon next is the end of the line number
  
          return lineInfo.substring(0, lineInfo.indexOf(&quot;:&quot;));
      }
  </code></pre>
  <p>The method above I print the stack which prints out correctly as I am expecting as below:</p>
  <pre><code>The stack is
  index.js:199 TypeError: Cannot read property 'toString' of null
      at sendHandledException (Home.js:18)
      at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
      at invokeGuardedCallback (react-dom.development.js:4056)
      at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070)
      at executeDispatch (react-dom.development.js:8243)
      at processDispatchQueueItemsInOrder (react-dom.development.js:8275)
      at processDispatchQueue (react-dom.development.js:8288)
      at dispatchEventsForPlugins (react-dom.development.js:8299)
      at react-dom.development.js:8508
      at batchedEventUpdates$1 (react-dom.development.js:22396)
      at batchedEventUpdates (react-dom.development.js:3745)
      at dispatchEventForPluginEventSystem (react-dom.development.js:8507)
      at attemptToDispatchEvent (react-dom.development.js:6005)
      at dispatchEvent (react-dom.development.js:5924)
      at unstable_runWithPriority (scheduler.development.js:646)
      at runWithPriority$1 (react-dom.development.js:11276)
      at discreteUpdates$1 (react-dom.development.js:22413)
      at discreteUpdates (react-dom.development.js:3756)
      at dispatchDiscreteEvent (react-dom.development.js:5889)
  </code></pre>
  <p>The next line is I perform a split on the new line characeters \r and \n  and then log out  the array that is created</p>
  <pre><code>0: &quot;TypeError: Cannot read property 'toString' of null&quot;
  1: &quot;    at sendHandledException (http://localhost:3000/static/js/main.chunk.js:642:24)&quot;
  2: &quot;    at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/0.chunk.js:8078:18)&quot;
  3: &quot;    at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/0.chunk.js:8127:20)&quot;
  4: &quot;    at invokeGuardedCallback (http://localhost:3000/static/js/0.chunk.js:8187:35)&quot;
  5: &quot;    at invokeGuardedCallbackAndCatchFirstError (http://localhost:3000/static/js/0.chunk.js:8202:29)&quot;
  6: &quot;    at executeDispatch (http://localhost:3000/static/js/0.chunk.js:12437:7)&quot;
  7: &quot;    at processDispatchQueueItemsInOrder (http://localhost:3000/static/js/0.chunk.js:12469:11)&quot;
  8: &quot;    at processDispatchQueue (http://localhost:3000/static/js/0.chunk.js:12482:9)&quot;
  9: &quot;    at dispatchEventsForPlugins (http://localhost:3000/static/js/0.chunk.js:12493:7)&quot;
  10: &quot;    at http://localhost:3000/static/js/0.chunk.js:12704:16&quot;
  11: &quot;    at batchedEventUpdates$1 (http://localhost:3000/static/js/0.chunk.js:26389:16)&quot;
  12: &quot;    at batchedEventUpdates (http://localhost:3000/static/js/0.chunk.js:7876:16)&quot;
  13: &quot;    at dispatchEventForPluginEventSystem (http://localhost:3000/static/js/0.chunk.js:12703:7)&quot;
  14: &quot;    at attemptToDispatchEvent (http://localhost:3000/static/js/0.chunk.js:10186:7)&quot;
  15: &quot;    at dispatchEvent (http://localhost:3000/static/js/0.chunk.js:10104:23)&quot;
  16: &quot;    at unstable_runWithPriority (http://localhost:3000/static/js/0.chunk.js:37465:16)&quot;
  17: &quot;    at runWithPriority$1 (http://localhost:3000/static/js/0.chunk.js:15484:14)&quot;
  18: &quot;    at discreteUpdates$1 (http://localhost:3000/static/js/0.chunk.js:26406:18)&quot;
  19: &quot;    at discreteUpdates (http://localhost:3000/static/js/0.chunk.js:7888:16)&quot;
  20: &quot;    at dispatchDiscreteEvent (http://localhost:3000/static/js/0.chunk.js:10070:7)&quot;
  </code></pre>
  <p>As you can see above, when I log out the stack where I've split by line, the output is completely different so I no longer have the data that I originally had when I first printed the console.</p>
  <p>How can I parse this exception.stack and maintain the original the content that first logged at the start of the method.</p>