regex_t rt1_;
int cflags = RE_SYNTAX_AWK;
cflags &= ~REG_NOSUB;
if (regcomp (&rt1_, // match: Interesting ports on 10.45.8.12:
"([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",
cflags) != 0)
{
ulogEx(ULOG_LL_WARNING, MESW_DEV_NM,MON_ULOG_MID,MON_ULOG_EC_TRACE,
"%s: reg comp error!\n\n", __func__);
}
static char ip [32];
regmatch_t rm [1];
memset (&rm, 0, sizeof rm);
if (0 == regexec (&rt1_, pline, 1, rm, 0))
{
strncpy (ip, &pline[rm[0].rm_so], rm[0].rm_eo-rm[0].rm_so+1);
ip [rm[0].rm_eo-rm[0].rm_so] = '\0';
return ip;
}
else
return NULL;
regfree (&rt1_);
posted on 2007-04-04 16:47
我爱佳娃 阅读(2670)
评论(0) 编辑 收藏 所属分类:
正则表达式