title: Removing html tags and unwanted characters in iOS
body: <p>I have the following method to remove the html tags and unwanted characters from a string:</p>
  
  <pre><code>-(NSString *) stringByStrippingHTML: (NSString*) s {
  NSRange r;
  while ((r = [s rangeOfString:@"&lt;[^&gt;]+&gt;" options:NSRegularExpressionSearch]).location != NSNotFound)
      s = [s stringByReplacingCharactersInRange:r withString:@""];
  while ((r = [s rangeOfString:@"&amp;#8217;" options:NSRegularExpressionSearch]).location != NSNotFound)
      s = [s stringByReplacingCharactersInRange:r withString:@"\'"];
  while ((r = [s rangeOfString:@"&amp;#8221;" options:NSRegularExpressionSearch]).location != NSNotFound)
      s = [s stringByReplacingCharactersInRange:r withString:@"\""];
  while ((r = [s rangeOfString:@"&amp;#8220;" options:NSRegularExpressionSearch]).location != NSNotFound)
      s = [s stringByReplacingCharactersInRange:r withString:@"\""];
  while ((r = [s rangeOfString:@"&amp;#8230;" options:NSRegularExpressionSearch]).location != NSNotFound)
      s = [s stringByReplacingCharactersInRange:r withString:@"..."];
  while ((r = [s rangeOfString:@"&amp;#8211;" options:NSRegularExpressionSearch]).location != NSNotFound)
      s = [s stringByReplacingCharactersInRange:r withString:@"-"];
  
  return s;
  }
  </code></pre>
  
  <p>I have too many while cases, how can this be done in a more elegant fashion? </p>