int errcode;
regex_t regexbuf;
- buf[0] = '\0';
+ buf[0] = '0';
AST_NONSTANDARD_APP_ARGS(args, parse, '"');
regerror(errcode, ®exbuf, buf, len);
ast_log(LOG_WARNING, "Malformed input %s(%s): %s\n", cmd, parse, buf);
return -1;
- } else {
- if (!regexec(®exbuf, args.str, 0, NULL, 0))
- strcpy(buf, "1");
}
+
+ strcpy(buf, regexec(®exbuf, args.str, 0, NULL, 0) ? "0" : "1");
+
regfree(®exbuf);
return 0;
static struct ast_custom_function regex_function = {
.name = "REGEX",
- .synopsis =
- "Regular Expression: Returns 1 if data matches regular expression.",
+ .synopsis = "Regular Expression",
+ .desc = "Returns 1 if data matches regular expression, or 0 otherwise.",
.syntax = "REGEX(\"<regular expression>\" <data>)",
.read = regex,
};