Regex

A perl compatible regular expression. This uses the PCRE2 library, and attempts to enable JIT matching whenever possible.

class ref Regex

Constructors

create

Compile a regular expression. Raises an error for an invalid expression.

new ref create(
  from: (String box | Array[U8 val] box),
  jit: Bool val = seq)
: Regex ref^ ?

Parameters

Returns


Public Functions

matches

Creates a match iterator from the regular expression that will iterate over the supplied subject returning matches.

fun box matches(
  subject: String val)
: MatchIterator ref

Parameters

Returns


eq

Return true on a successful match, false otherwise.

fun box eq(
  subject: (String box | Array[U8 val] box))
: Bool val

Parameters

Returns


ne

Return false on a successful match, true otherwise.

fun box ne(
  subject: (String box | Array[U8 val] box))
: Bool val

Parameters

Returns


apply

Match the supplied string, starting at the given offset. Returns a Match object that can give precise match details. Raises an error if there is no match.

fun box apply(
  subject: (String val | Array[U8 val] val),
  offset: USize val = seq)
: Match ref^ ?

Parameters

Returns


replace[optional A: (Seq[U8 val] iso & (String iso | Array[U8 val] iso))]

Perform a match on the subject, starting at the given offset, and create a new string using the value as a replacement for what was matched. Raise an error if there is no match.

fun box replace[optional A: (Seq[U8 val] iso & (String iso | Array[U8 val] iso))](
  subject: (String val | Array[U8 val] val),
  value: (String box | Array[U8 val] box),
  offset: USize val = seq,
  global: Bool val = seq)
: A^ ?

Parameters

Returns

  • A^ ?

split

Split subject by non-empty occurrences of this pattern, returning a list of the substrings.

fun box split(
  subject: String val,
  offset: USize val = seq)
: Array[String val] iso^ ?

Parameters

Returns


index

Returns the index of a named capture. Raises an error if the named capture does not exist.

fun box index(
  name: String box)
: USize val ?

Parameters

Returns


dispose

Free the underlying PCRE2 data.

fun ref dispose()
: None val

Returns


Private Functions

_match

Match the subject and keep the capture results. Raises an error if there is no match.

fun box _match(
  subject: (String box | Array[U8 val] box),
  offset: USize val,
  options: U32 val)
: Pointer[_Match val] ref ?

Parameters

Returns


_final

Free the underlying PCRE2 data.

fun box _final()
: None val

Returns