The fmpcre module adds the pcre_match() function for PCRE-style regular expression matching in RainerScript.

fmpcre (PCRE matching)

Purpose

The fmpcre function module provides pcre_match() for matching strings with PCRE-style regular expressions. Unlike re_match(), which uses POSIX ERE, pcre_match() supports PCRE syntax such as lookarounds and inline modifiers.

Requirements

This module is optional and requires the PCRE development library to be installed at build time. Enable it during configure:

./configure --enable-fmpcre

Example

Load the module before calling the function:

module(load="fmpcre")
set $.hit = pcre_match($msg, "^foo.*bar$");

Function

pcre_match(expr, re)

Returns 1 when expr matches the PCRE pattern re, otherwise 0. The re argument must be a constant string so the expression can be compiled during configuration parsing.

Note

PCRE matching can be more expensive than simple string operations. Consider cheaper filters before using complex expressions.


Support: rsyslog Assistant | GitHub Discussions | GitHub Issues: rsyslog source project

Contributing: Source & docs: rsyslog source project

© 2008–2025 Rainer Gerhards and others. Licensed under the Apache License 2.0.