This is the ThingsDB documentation for version v0, click here for the latest version!

test

This function is deprecated and should be replaced with test(..) on type regex.

Test if a string matches a given regular expression and return true or false.

This function does not generate an event.

Function

str.test(regex)

Arguments

Argument Type Description
regex regex (required) The regular expression to test against the string.

Return value

true if there is a match between the string and the specified regular expression, otherwise false.

Example

Examples using test():

[
    'Hello world!!'.test(/^hello/),
    'Hello world!!'.test(/^hello/i),
];

Return value in JSON format

[
    false,
    true
]