title: How to figure out the range of a substring in one string and then use it in another
body: <p>Basicly I want something like this,</p>
  <pre><code>NSString* foobar(NSString *input) {
      // say input is &quot;1&quot;
      NSString *string = @&quot;0123456789&quot;;
      NSString *anotherString = @&quot;零一二三四五六七八九&quot;;
      
      NSRange range = [string rangeOfString:input];
      
      // return &quot;一&quot; here
      return [anotherString substringWithRange:range];
  }
  </code></pre>
  <p>I tried the same stuff in Swift,</p>
  <pre><code>func foobar(input: String) -&gt; String {
      // say input is &quot;1&quot;
      let string = &quot;0123456789&quot;
      
      let range = string.range(of: input, options: .anchored)
      let result = anotherString[range!]
      
      // return &quot;012&quot; here
      return String(result)
  }
  </code></pre>
  <p>why?
  And how can I achieve this?</p>