I am trying to validate an email address using regcomp and regexec. However, aparently I am doing it incorrectly.
When I use a simple pattern to match things work well. However, as soon as I start getting into the special escaped regex code it starts to fail. I'm assuming that the pattern is being changed by the compiler due to the escapes.
I've tried double escapes and quadruple escapes. Any clue what I am doing wrong?
The pattern I am trying to use is
char * pattern = "^[a-zA-Z][\\\\w\\\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\\\w\\\\.-]*[a-zA-Z0-9]\\\\.[a-zA-Z][a-zA-Z\\\\.]*[a-zA-Z]$";
When I use a simple pattern to match things work well. However, as soon as I start getting into the special escaped regex code it starts to fail. I'm assuming that the pattern is being changed by the compiler due to the escapes.
I've tried double escapes and quadruple escapes. Any clue what I am doing wrong?
The pattern I am trying to use is
char * pattern = "^[a-zA-Z][\\\\w\\\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\\\w\\\\.-]*[a-zA-Z0-9]\\\\.[a-zA-Z][a-zA-Z\\\\.]*[a-zA-Z]$";