Remove Index [number] from string : <p>Using Typescript I have an array of objects as follows:</p>

<pre><code>var errors = [
  { name: "Emails[2]", message: "Email is invalid" }
  { name: "Role", message: "Role is required" }
];
</code></pre>

<p>The <code>name</code> can be:<br>
1. A string like <code>"Role</code>".<br>
2. A string followed by brackets and number like <code>"Emails[2]"</code>.</p>

<p>In case of (2) I would like to replace <code>"Emails[2]"</code> simply by <code>"Emails"</code>.</p>

<p>Every object with <code>name</code>=<code>text[number]</code> would have the <code>name</code> updated to <code>text</code>.</p>

<p>How can I do this?     </p>
