ballerina/regex

Package overview

This package provides the following regex utility functions.

  • matches - Checks whether a string matches a given regex.
  • replaceAll - Replaces every occurrence of a substring that matches a given regex in a string, with another string provided.
  • replaceFirst - Replaces the first occurrence of a substring that matches a given regex in a string, with another string provided.
  • split - Splits a string using a given regex delimiter and returns an array of the split elements.

Functions

[4]

matches

Checks whether the given string matches the provided regex.

replaceAll

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

replaceFirst

Replaces the first substring that matches the given regular expression with the provided `replacement` string.

split

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