objective c - Regex Issue- can't get it to accept my expression -


i running following code, regex object nil , error telling me regex invalid (works fine in regex tester!)

nserror *err = nil;     nsstring *pattern = @"({{[^}]*}})";     nsregularexpression* regex = [nsregularexpression regularexpressionwithpattern: pattern                                                                            options: nsregularexpressioncaseinsensitive                                                                              error: &err]; 

do need escape in there? tried adding \ before each curly brace, did not work either...

you need two backslashes both escape character strings , regular expressions, \\ enters single backslash string, , regular expression parser sees backslash , escapes brace: @"(\\{\\{[^}]*\\}\\})"


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -