I'm looking to strip the whitespace out of the beginning and end of my string. I'm using the following regular expression.
NSString *pattern = @"(?:^\s+|\s+$)";
This is coming up with an error that \s
is not a valid escape character. Replacing this with \\s
appears to work but what I'd like to know is why? I thought \s
is a whitespace charecter and \\s
would give me a literal string of '\s'?