objective c - iOS Regex: Unknown escape sequence "\|" -


I am getting a strange warning, and as a result my regex search is not working. Here's the line:

  NSRang R = [HTML categoryoffstring: @ "\ | (*. *) \ |" Options: NSRegularExpressionSearch];   

Where html is a string which I'm sure is a single match for regex above.

The warning only

You are getting a warning because \ | Objective-C (or C or C ++ for that matter) does not have a valid Escape sequence. The compiler is ignoring it and instead a raw | is using the character, so the string you are actually passing is @ "| (. *)." .

You want to get the behavior, you have to run backslash in your source code so that the regex engine can see the literal backslash and | Alternately translate the character as a translation, such as @ "\\ | (* * * \\ |" .

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -