.. highlightlang:: us .. index:: regex .. _regex: regex ===== .. us.tag regex NOTREADYENGLISH STR New311 Changed570 Changed5140 :ref:`regex` checks if elements of a string vector matches a regular expression. .. function:: b = regex(ssRegex, svString) b = regex(ssRegex, svString, flags) .. us.return **Return Value** *b* is a real vector of size len(svString). *b[i]* contains the vlaue 1 if *svString[i]* matches the regular expression and otherwise 0. .. us.params **Parameters** .. uparam:: ssRegex *ssRegex* is a scalar string. .. uparam:: svString *ssString* is a string vector. .. uparam:: flags .. list-table:: :header-rows: 0 * - REG_ICASE (0x01) - * - REG_NEWLINE (0x02) - * - REG_NOTBOL (0x04) - * - REG_NOTEOL (0x08) - * - REG_UTF8 (0x40) - .. us.example **Example** :: def issym(svSym) { ssReg = "^[_A-Za-z][_A-Za-z0-9]*$" return regex(ssReg, svSym) } issym(["a", "_a", "1a"]) The following example returns 1 if ssName is the string ``grid`` followed by 0 or more numbers, e.g. grid, grid1, grid27: :: regex("grid[0-9]*$", ssName); Returns 1 for integer number, e. g. -1000 or +1287 or 1356: :: regex("^[-+]?(\d)*$", ssText) .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - 5.14.0 - New PCRE version 8.0. * - 5.7.0 - New parameter *flags*. * - 3.1.1 - New .. us.comment **Comment** Regular expression support is provided by the PCRE library package, which is open source software, written by Philip Hazel, and copyright by the University of Cambridge, England. Version 8.0. License: See :ref:`pcre-license`. Documentation: See :ref:`regsplit` .. seealso:: :ref:`overview-strings`, :ref:`regsplit`, :ref:`strtok`, :ref:`strextract`, :ref:`strmatch`, :ref:`strmatchi` :sub:`id-742151`