title: Regex to extract first 10 characters of a string
body: <p>There are two scenarios</p>
  
  <p><strong>First case:</strong></p>
  
  <p>I have an html string for example,</p>
  
  <pre><code> var str1="&lt;b&gt;hello how are you&lt;/b&gt;&lt;h1&gt;how to extract the first 10 characters of a htmlstring without losing the html of the string&lt;/h1&gt;";
  </code></pre>
  
  <p>I have to extract the first 10 characters of a string without loosing the html. So that the expected output is</p>
  
  <pre><code>&lt;b&gt;hello how a&lt;b&gt;...
  </code></pre>
  
  <p><strong>Second Case:</strong></p>
  
  <p>I have a simple string as below</p>
  
  <pre><code>var str1="hello how are you.how to extract the first 10 characters of a htmlstring without losing the html of the string";
  </code></pre>
  
  <p>I have to extract the first 10 characters of a string . So that the expected output is</p>
  
  <pre><code>hello how a...
  </code></pre>
  
  <p>I want an regex expression thact could be applied for both these cases.</p>
  
  <p>I am new to regex.. I have tried a lot but I dont have any working code so that I could post it here.Please help.</p>