regexΒΆ

regex checks if elements of a string vector matches a regular expression.

b = regex(ssRegex, svString)
b = regex(ssRegex, svString, flags)

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

ssRegex

ssRegex is a scalar string.

svString

ssString is a string vector.

flags
REG_ICASE (0x01)  
REG_NEWLINE (0x02)  
REG_NOTBOL (0x04)  
REG_NOTEOL (0x08)  
REG_UTF8 (0x40)  

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)

History

Version Description
5.14.0 New PCRE version 8.0.
5.7.0 New parameter flags.
3.1.1 New

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 PCRE.

Documentation: See regsplit

id-742151