C compiler warning Unknown escape sequence '\.' using regex for c program

后端 未结 2 596
余生分开走
余生分开走 2021-02-18 22:18

I am using regex to determine a command line argument has the .dat extension. I am trying the following regex:

#define to_find \"^.*\\.(dat)?\"

2条回答
  •  梦毁少年i
    2021-02-18 22:38

    You need

    #define to_find "^.*\\.(dat)?"
    

    Should do the trick as the \ needs to be escaped for C and not the benefit for regex at this stage

提交回复
热议问题