title: NSRange, Find a word within a paragraph getting wrong results
body: <p>Ive written a method to highlight a word within a paragraph by sending it an <code>NSString</code> of that word, it was working perfectly until i faced this scenario:</p>
  
  <p>When i have this text: </p>
  
  <blockquote>
    <p>Their mother has tried dressing them in other ...</p>
  </blockquote>
  
  <p>When I'm passing the word <code>other</code>, the word "m<code>other</code>" is being highlighted, also when I'm passing <code>in</code> i got "dress<code>in</code>g".</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>-(void)setTextHighlited :(NSString *)txt{
      NSMutableAttributedString * string = [[NSMutableAttributedString alloc]initWithString:self.textLabel.text];
  
      for (NSString *word in [self.textLabel.text componentsSeparatedByString:@" "]) {
  
          if ([word hasPrefix:txt]) {
              NSRange range=[self.textLabel.text rangeOfString:word];
              [string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:range];
      }
  </code></pre>
  
  <p>I've tried to use <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/rangeOfString:options:" rel="nofollow noreferrer">rangeOfString:options:</a> with all of its options, but still have the same problem.</p>
  
  <p>Please advice</p>
  
  <p><strong>PS:</strong> <a href="https://stackoverflow.com/a/20171450/1091539">This is the source of my code</a></p>