Ad Widget

Collapse

regular expressions and new lines

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skogan
    Member
    • Nov 2007
    • 70

    #1

    regular expressions and new lines

    Hi.

    I have stumbled across a slightly weird thing in the Zabbix source. In the file "regxp.c":
    Code:
    static  char    *zbx_regexp(const char *string, const char *pattern, int *len, int flags)
    ....
                    if ( 0 == regcomp(&re, pattern, REG_EXTENDED | /* REG_ICASE | */ REG_NEWLINE) )
     ...
    The REG_NEWLINE flag here is really counterintuitive for web monitoring steps. It essentially means that unless a regex has a "^" in it, it will be limited to single lines.

    Then there is that:
    Code:
    char    *zbx_iregexp_match(const char *string, const char *pattern, int *len)
    {
            return zbx_regexp(string, pattern, len, REG_EXTENDED | REG_ICASE | REG_NEWLINE);
    }
    However, in zbx_regexp above, we can see that the flags passed by zbx_iregexp_match will be ignored. Essentially, the iregxp function will still be case sensitive. Is there a specific reason for this, or is it a bug?
Working...