Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 2
    this would trim it also from the end of the string Commented Mar 12, 2016 at 21:13
  • 1
    @t1. you can use letterCharacterSet invertedSet Commented Mar 12, 2016 at 21:18
  • 1
    @LeoDabus totally missed that there were spaces in the requirements as well. In that case, inverted set is probably the best idea. Commented Mar 12, 2016 at 21:21
  • 1
    Trim is still not the best solution, it cuts off the end also, which is not acceptable here. Commented Mar 12, 2016 at 22:13
  • 1
    If your string can ever end in digits then stringByTrimmingCharactersInSet is not a good choice. It trims away characters in the specified set from the beginning AND end of the string, until the first occurrence of a character not in the specified set. So "012Red Apple8675309" would get trimmed to "Red Apple". Commented Mar 12, 2016 at 22:49