BDE 4.14.0 Production release
|
Provide a utility class for string pattern matching.
This component defines a namespace, ball::PatternUtil
, that provides utility functions for matching input strings to a given pattern based on wild-card and simple escape sequences.
This component participates in the implementation of "Rule-Based Logging". For more information on how to use that feature, please see the package level documentation and usage examples for "Rule-Based Logging".
This section illustrates intended use of this component.
The following code fragments illustrate basic usage of this component's utility functions.
A string matches a pattern if they are identical:
A string matches a pattern containing an (unescaped) trailing *
if that pattern (without the trailing *
) is a prefix of the string:
An escaped *
at the end loses its wild-card semantics and matches a single *
:
Escape sequences include '\' and '*' only and they can appear anywhere in the pattern:
A pattern is invalid if it contains a non-trailing *
, or any '\' that is not followed by either '\' or *
. The isValidPattern
function can be used to determine whether or not a pattern is valid:
The isMatch
function always returns false
on an invalid pattern: