我正在使用 slre ( https://code.google.com/p/slre/ ) 为 ac 程序提供正则表达式库。
我想用以下模式匹配一个 IP 地址:"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
我收到以下编译错误:Warning: unknown excape sequence '\.' 我也试过用'\\。' --> 编译错误消失了,但还是说不匹配。
if (!slre_compile(&slre, settings[i].regex)) {
printf("Error compiling RE: %s\n", slre.err_str);
}
else if (!slre_match(&slre, settings[i].value, strlen(settings[i].value), captures)) {
printf("\nSetting '%s' does not match the regular expression!", settings[i].internName);
}
settings[i].regex 是一个 char* 与我上面提到的正则表达式 settings[i].value 是一个 char* 我要匹配的字符串是 8.8.8.8
有没有其他方法可以检查一个点?