When using regex in C, \d does not work but [0-9] does

前端 未结 4 576
面向向阳花
面向向阳花 2020-12-11 08:07

I do not understand why the regex pattern containing the \\d character class does not work but [0-9] does. Character classes, such as \\s

4条回答
  •  既然无缘
    2020-12-11 08:38

    \d is a perl and vim character class.

    Use instead:

     const char *rstr = "^[[:digit:]]+\\s+\\w+\\s+[[:digit:]]+\\s+\\w+$"; 
    

提交回复
热议问题