smartsanja
smartsanja

Reputation: 4540

"Unknown escape sequence" warning for regex

I'm getting following warnings as a result my regex. Here's the line:

#define REGEX_FEILD_USERNAME @"[/\A[^0-9`!@#\$%\^&*+_=]+\z/]"

Warnings

unknown escape sequence \z
unknown escape sequence \A
unknown escape sequence \$
unknown escape sequence \^

How to solve this?

Upvotes: 0

Views: 1469

Answers (1)

trojanfoe
trojanfoe

Reputation: 122391

As that string will be seen by the compiler you need to escape the \ characters as they have meaning within string literals:

#define REGEX_FEILD_USERNAME @"[/\\A[^0-9`!@#\\$%\\^&*+_=]+\\z/]"

Upvotes: 1

Related Questions