Regex_match

miscellaneous-functions regex_match

syntax

  • regex_match(source, syntax, optionalflag)

definition

regex_match(source, syntax, optionalflag) results in a boolean data-item indicating if the source data item matches the syntax expressed by the syntax argument.

A third optional argument optionalflag can be configured to control how the source string is matched against the syntax expressed by the syntax argument.

description

regex_match uses the boost 1.51 regex_match function. Click here for valid regex syntax rules and semantics.

The third, optionalflag argument is optional. More information on this argument can be found here.

In the GeoDMS this argument is passed as a uint32 parameter, see the enumeration of regex-flags.

applies to

since version

7.011

example

parameter<string> Text  := dquote('Corop') + ';' + dquote('CoropLabel');
parameter<string> Quote :=  quote('Corop') + ';' +  quote('CoropLabel');
parameter<string> Comma := dquote('Corop') + ',' + dquote('CoropLabel');

// the following regex_match functions check if the text parameters only
// contain double quoted column names separated by semicolons
// and no other characters

parameter<bool> T := regex_match(text,  '"[^"]*+"(;"[^"]*+")*+'); // result = True
parameter<bool> Q := regex_match(quote, '"[^"]*+"(;"[^"]*+")*+'); // result = False (due to single quote)</I>
parameter<bool> C := regex_match(comma, '"[^"]*+"(;"[^"]*+")*+'); // result = False (due to comma)</I>

Example from the Land Use Scanner for reading TigrisXL output files.

parameter<string> Validator := '\\s*-?\\d+(\\.\\d+)?\\s*';

This translates to:

  • zero or more spaces
  • zero or one minus sign
  • one or more digits
  • (optional: a decimal point followed by one or more digits)
  • zero or more spaces

common operators

  • The * operator will match the preceding atom zero or more times
  • The + operator will match the preceding atom one or more times
  • The ? operator will match the preceding atom zero or one times
  • The escape character \d is equivalent to a digit, whereas \D shall match any character not in that class.
  • The escape character \w is equivalent to a word, whereas \W shall match any character not in that class.
  • The escape character \s is equivalent to a space, whereas \S shall match any character not in that class.

see also