MATCHLENGTH Function

Returns the length of the last pattern match found.

Category: Regular Expression
Interaction: This function operates on the pattern match substring found using FINDFIRST( ) or FINDNEXT( ).
Returned data type: Integer

Syntax

r.MATCHLENGTH( )

Without Arguments

There is no argument for this function.

Details

Use the MATCHLENGTH function to determine the length in characters of the currently matched pattern found with FINDFIRST( ) or FINDNEXT( ). Used in conjunction with MATCHSTART( ), this function can be used to find matching substrings and populate variables in your expression code.

The function returns a positive integer value that represents the number of characters found to be a pattern match of the regular expression. NULL is returned if there is no substring currently under consideration and therefore no length to return.

Example

Note: This example can be run in a stand-alone expression node if the Generate rows when no parent is specified option is selected. If passing data to this node instead, turn this setting off and remove the SETEOF() function. Unless stated otherwise, all code shown should be entered in the Expression tab of the Expression node.

// Define some variables

integer i

string MyString

 

//Supply some values for the variables

i = 0

MyString = "DataFlux"

// Uncomment the line below to see the value of variable i change

//MyString = "Data_Management_Studio"

 

//You must define a regex object

regex r

//Then compile your regular expression.

// This expression will match as many "word" characters as it can

// (alphanumerics and undescore)

r.compile("\w*")

// If a pattern match is found then set i to show the length of

// the captured substring

if r.findfirst(MyString) then i = r.matchlength()

// Terminate the expression node processing

seteof()