[]
        
(Showing Draft Content)

MATCH

This function helps to find whether the text matches a regular expression. 

Syntax 

SJS.REGEXMATCH(text, regular_expression, [modifiers])

Arguments 

This function has the following arguments: 

Argument 

Description 

text 

Refers to the text you are trying to test against the regular_expression. 

regular_expression 

Refers to a regular expression to test the text against. 

modifiers 

[Optional] Input to define the pattern. 

  • g (global): retains the index of the last match and allows subsequent searches to start from the end of the previous match. 

  • i (ignore case): makes the whole expression case insensitive. 

  • m (multiline): when enabled, beginning and end anchors are matched with the start and end of a line, instead of the start and end of the whole string. 

  • u (unicode): when enabled, you can use extended unicode escapes in the form. 

  • s (dotall): dot is matched to any character, including newline. 

Remarks

  • You can use this function with text (not numbers) as input and return a logical value, i.e., TRUE or FALSE as output. 

  • If you want to use a number as input, convert them to text using the TEXT function. 

Examples 

SJS.REGEXMATCH("SpreadJS Supports 400 functions.", "\d+") gives the result TRUE

SJS.REGEXMATCH("My Name is (John Smith)", "\(([\w]+)\)") gives the result TRUE

SJS.REGEXMATCH("Red", "[^red]", "i") gives the result FALSE

Errors 

  • returns a #VALUE! error if the value type of text or regular_expression is not text. 

  • returns a #N/A error if the length of the parameters < 2. 

  • returns a #NAME error if any parameter is not valid.