regex

regex

factory regex

Description:
  • Specifies the regular expression (regex) specific functions.

    • The regex pattern is a string with a special syntax that describes what constitutes a match, using the ECMAScript syntax.
    • It appears that some regex catching multiline string may fail or induce infinite loops:
      • The solution is to convert a multiline string into a single line string, e.g.:
        aidesys::regexReplace(aidesys::regexReplace(string, "\\s+", " "), regex_for_single_line, output)
    • These functions are accessible via the aidesys:: prefix.

Methods

(static) regexMatch(string, regex) → {bool}

Description:
  • Regular expression match function.

Parameters:
Name Type Description
string string

The input string.

regex string

The regular-expression to match, following the ECMAScript syntax syntax.

Returns:

True if the whole string match the regex, false otherwise.

Type
bool

(static) regexIndexes(string, regex) → {vector}

Description:
  • Regular expression localisation function.

Parameters:
Name Type Description
string string

The input string.

regex string

The regular-expression to match, following the ECMAScript syntax syntax.

Returns:

An std::vector<std::array<unsigned int, 2>> of the form { {position, length}, ...} with all matched string position and length.

Type
vector

(static) regexReplace(string, regex, output) → {string}

Description:
  • Regular expression replace function.

Parameters:
Name Type Description
string string

The input string.

regex string

The regular-expression to match, following the ECMAScript syntax syntax.

output string

The output pattern.

Returns:

The string replacements of all matched expression, if any, else the original string.

Type
string

(static) regexSplit(string, regex) → {Array.<string>}

Description:
  • Splits a string as vector of token.

Parameters:
Name Type Description
string string

The input string.

regex String

The regex delimiter.

Returns:

A std::vector<std::string> with the string items.

Type
Array.<string>