dynPatternMatch()

Checks whether particular strings in a dynamic field have a specific pattern.

Synopsis

dyn_string dynPatternMatch ( string pattern, dyn_string ds);

Parameters

Parameter Description
pattern Pattern-String
ds Array, whose strings are to be checked

Return Value

Returns the strings, which meet the pattern, in an array.

Errors

Description

Checks whether the elements in the array ds possess the pattern specified in pattern . The asterisk "*" replaces any number of characters, the question mark "?" replaces any character, characters in square brackets one of the characters specified in brackets.

Under Linux, the same rules for pattern apply as those that apply for Linux command lines for addressing files: These rules can be retrieved by using "man 5 regexp" on Linux computers.

Example

The function checks the pattern "*a" for the following strings: "abc", "cdea", "abcd", "cdeafgh", "bbacc", "xyz".

main()
{
  string pattern;
  dyn_string ds1, ds2;
  pattern = "*a";
  ds1 = makeDynString("abc", "cdea", "abcd", "cdeafgh", "bbacc",
  "xyz");
  ds2 = dynPatternMatch(pattern, ds1);
  DebugN("The pattern is valid for: " + ds2); //Return value is
  "cdea"
}

The function checks the pattern "?y?" in the following strings: "abc", "cdea", "abcd", "cdeafgh", "bbacc", "xyz".

main()
{
  string pattern;
  dyn_string ds1, ds2;
  pattern = "?y?";
  ds1 = makeDynString("abc", "cdea", "abcd", "cdeafgh", "bbacc",
  "xyz");
  ds2 = dynPatternMatch(pattern, ds1);
  DebugN("The pattern is valid for: " + ds2); //Return value is
  "xyz"
}

Assignment

Dynamic arrays

Availability

CTRL