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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -