patternMatch()

Checks whether a string has a particular pattern.

Synopsis

bool | dyn_bool patternMatch(string pattern, string s | dyn_string ds);

Parameters

Parameter Description
pattern Pattern string. Pattern is case-sensitive also for Windows platform.
s Character string to be checked

Return value

The function returns TRUE if the pattern matches otherwise, FALSE.

Error

Description

Checks whether the strings has the pattern specified in pattern. The asterisk "*" replaces any number of characters whereas the question mark "?" replaces any particular character and characters in brackets replace one of the characters specified in the brackets.

Note: When you search for a pattern by using an asterisk or a question mark, escape characters must be used as follows: DebugTN(patternMatch("*\\[", "hello["));
Note: Within the brackets [] the characters "*" and "?" are interpreted as normal characters and not as wildcards

Example

The following example checks the correct and incorrect patterns for the string "otto.cc".

main()
{
  bool retVal1, retVal2;
  retVal1 = patternMatch("*.[abc]c", "otto.cc");
  retVal2 = patternMatch("*.?", "otto.cc");
}

Assignment

Strings

Availability

UI, CTRL