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?
Use two backslashes:
"space here".rangeOfString("\\s", options: .RegularExpressionSearch)
(a single backslash is treated as an escape character).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With