iOS Regex: Unknown escape sequence "\|"
You're getting the warning because \|
is not a valid escape sequence in Objective-C (or C or C++ for that matter). The compiler is ignoring that and just using a raw |
character instead, so the string you're actually passing in is @"|(.*)|"
.
To get the behavior you want, you have to escape the backslash in your source code so that the regex engine sees the literal backslash and interprets the |
character as a literal instead of as alternation, e.g. @"\\|(.*)\\|"
.
Just to add up, if you are dealing with special character sequences in unicode format, you can use something like this:
const unichar specialCharSequence='some special character';if(specialCharSequence==L'\uxxxx'){ //handle the occurence of this special character}