ConnectorLib Java 25.1
ConnectorLib Java SDK Programming Guide

# regex_match

Tests whether an input string matches a regular expression. The full string must match the regular expression, otherwise the function returns `nil`. To find matches within a string, OpenText recommends using the function regex_search.

## Syntax

    regex_match( input, regex [, case] )

## Arguments

Argument | Description
--- | ---
`input` | (string) The input string.
`regex` | (string) The regular expression to match against.
`case` | (boolean) A boolean that specifies whether the match is case-sensitive. The match is case sensitive by default (`true`).

## Returns

One or more strings, or `nil`.

If the string matches the regular expression, and the regular expression has no sub-matches, the full string is returned.

If the string matches the regular expression, and the regular expression has sub-matches, then only the sub-matches are returned.

If the string does not match the regular expression, there are no return values (any results are `nil`).

You can assign multiple strings to a table. To assign the return values to a table, surround the function call with braces. For example:

    matches = { regex_match( input, regex ) }

## Examples

    local r1, r2, r3 = regex_match( "abracadabra", "(a.r)((?:a.)*ra)" )

Results: `r1="abr"`, `r2="acadabra"`, `r3=nil`

    local r1, r2, r3 = regex_match( "abracadabra", "a.r(?:a.)*ra" )

Results: `r1="abracadabra"`, `r2=nil`, `r3=nil`

Copyright 2024 Open Text
Version 25.1 | Last updated January 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery ConnectorLib Java 25.1

Topic Title: regex_match