ballerina/regex

Overview

This module provides APIs for searching, splitting, and replacing the set of characters of a string. These APIs are using a regular expression as a String to perform these operations by finding the string matches.

Regular expressions, are notations for describing sets of character strings. If a particular string is in the set described by a regular expression, the regular expression matches that string.

For information on the operations, which you can perform with the regex module, see the below Functions.

Functions

[7]

matches

Checks whether the given string matches the provided regex.

replace

Replaces the first substring that matches the given regex with the provided replacement string or string returned by the provided function.

replaceAll

Replaces each occurrence of the substrings, which match the provided regex from the given original string value with the provided replacement string.

replaceFirst
D

Replaces the first substring that matches the given regex with the provided replacement string.

Returns the first substring in str that matches the regex.

searchAll

Returns all substrings in string that match the regex.

split

Returns an array of strings by splitting a string using the provided regex as the delimiter.

Object types

[1]

Groups

Abstract object representation to hold information about matched regex groups.

Records

[1]

Match

Holds the results of a match against a regular expression.

Types

[1]

Replacement

A type to be used to get a replacement string.