title: Get the value of a string that matches a Regex
body: <p>How to replace a string that matches a regular Expression in typescript</p>
  <p>Here is my regular expression and string that matches the given pattern should be replaced as in the code</p>
  <pre><code>let formattedString = result.replace(/^&lt;p&gt;(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?/img, '&lt;p&gt;&lt;a href=$1 target=&quot;_blank&quot; style=&quot;cursor:pointer&quot;&gt;$1&lt;/a&gt;');
  </code></pre>
  <p>the result I've is - <code>&lt;p&gt;demo.test.io&lt;/p&gt;</code></p>
  <p>Now I want to replace this one as - <code>&lt;p&gt;&lt;a href=&quot;demo.test.io&quot; target=&quot;_blank&quot;&gt;demo.test.io&lt;/a&gt;&lt;/p&gt;</code></p>
  <p>Thank you</p>