1

I've used this question

How to remove special characters from string in Swift 2?

Which designates which characters to keep in a string, then removes all other characters. The function works great. The line

Set("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890+-*=(),.:!_".characters)

determines what characters to keep. However, when I try to add in the single quote character ('), single quotes are not kept. I tried escaping the single quote with \' and putting it in regularly, but to no avail. I don't believe single quotes need to be escaped in Swift.

Would someone care to enlighten me on this issue?

Thanks!

Community
  • 1
  • 1
CdSdw
  • 349
  • 1
  • 6
  • 19
  • 2
    I tried adding the single quote to the `Set` in the example you linked and it worked properly. Would you mind adding a full code sample of the problem? – Aaron Dec 07 '15 at 04:18

1 Answers1

0

Nevermind! As it turns out, I was calling the removeSpecialCharsFromString function inside a do-catch. Once I moved it outside of the do-clause, everything worked.

CdSdw
  • 349
  • 1
  • 6
  • 19