title: Remove all characters except last n characters from a string
body: <p>i am trying to remove all text except last 10 characters but getting error in android</p>
  
  <pre><code> 09-15 16:22:58.146: E/AndroidRuntime(13630): java.lang.StringIndexOutOfBoundsException: length=228; index=263
  </code></pre>
  
  <p>but it is working on java when i tried it in separate class.
  here is what i tried? can anybody tell me if there is any issue regarding substring in android?</p>
  
  <pre><code>String allchar = 
  "PJGOGROG fnkmslkjsfsdmnsgdnklnsgklsgknlgrf jkghijgdlkjkgjdfkjgf kjlgdfkjlfdgfjklklj
  kljfdkjlfkjldfdkjslkljdfskjlfsjkldfsjklkljs
  fdsjklsdfkljsfdkljkhgfhhgdfsgkhdfskghfdskghfdsghsfdghafevbhfsvgydcgubcdmgycdgfehkhfeghjgh68
  Alias12345";
  
      String  number = "";
      String reqtext = allchar.replaceAll("\\s+","");
      number = reqtext.substring(reqtext.length()-10 );
      System.out.println(number);
  </code></pre>