viv:test
Tests if a string matches a pattern.
Synopsis
boolean
viv:test
(str, pattern, pattern-type);
string str;
string pattern;
"wc"|"wc-set"|"regex"| "perl-regex" | "case-insensitive-regex" | "case-insensitive-perl-regex" pattern-type;
Description
Test if a string matches a certain pattern.
Arguments
- str: string on which to try to match the pattern
- pattern: pattern to be matched.
- pattern-type: the type of pattern-matching that should be used in
the comparison, which is one of the following:
- wc - a single expression that contains alphanumeric characters plus any number of '?' or '*' characters that can, respectively, match any single character or any sequence of characters
- wc-set - multiple wc expressions, which are separated from each other by an OR symbol ('|')
- regex - a single expression that contains any number of alphanumeric characters and special characters such as '?', '.', '*', '+', '(', ')', '{', '}', '[', and ']', plus special characters such as '^' and '$' that combine to identify a pattern of characters to be matched. The Watson™ Explorer Engine regex pattern type conforms to the POSIX specification, and therefore only handles single-byte ASCII characters. To match multi-byte UTF-8 characters, you must use the perl-regex or case-insensitive-perl-regex pattern types. For more detailed information about using POSIX regular expressions in Watson Explorer Engine. See POSIX Regular Expression Syntax and Examples.
- cregex - a deprecated synonym for the Watson Explorer Engine case-insensitive-regex pattern type. This pattern type is only supported for compatibility with older releases of Watson Explorer Engine, and should not be used in new projects.
- perl-regex - a single expression that contains any number of alphanumeric characters and special characters such as '?', '.', '*', '+', '~', '(', ')', '{', '}', '[', and ']', plus special characters such as '^' and '$' that combine to identify a pattern of characters to be matched. The Watson Explorer Engine perl-regex pattern type uses the Perl-Compatible Regular Expression (PCRE) library, and therefore conforms to the regular expression syntax supported by Perl version 5, most notably where '.' matches multi-byte UTF-8 characters. For more information about using Perl-style regular expressions in Watson Explorer Engine, see Perl Compatible Regular Expression Syntax.
- case-insensitive-regex - a case-insensitive version of the Watson Explorer Engine regex pattern type. Any alphabetic, single-byte characters that are specified in the pattern match both the upper and lowercase versions of that character. To match upper and lowercase versions of multi-byte UTF-8 characters, you must use the case-insentitive-perl-regex patern type.
- case-insensitive-perl-regex - a case-insensitive version of the Watson Explorer Engine perl-regex pattern type. Any alphabetic UTF-8 characters that are specified in the pattern match both the upper and lowercase versions of that character.
The default value for this parameter is wc-set.
Returns
True in case of match, false if there is no match
Example
<xsl:if test="viv:test(document/@url, 'http://*.pdf', 'wc')">
...
</xsl:if>