Reputation: 11107
I want to regex a string and see if there is an empty space inside it. Unfortunately due to Swift's use of \
inside double quotes, the code below produces an error.
"space here".rangeOfString("\s", options: .RegularExpressionSearch)
How can I regex to see if an empty space is inside the string?
Upvotes: 4
Views: 9470
Reputation: 72854
Use two backslashes:
"space here".rangeOfString("\\s", options: .RegularExpressionSearch)
(a single backslash is treated as an escape character).
Upvotes: 14