Skip to content

Regex

[Source]

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

class ref Regex

Constructors

create

[Source]

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

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

Parameters

Returns


Public Functions

matches

[Source]

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

[Source]

Return true on a successful match, false otherwise.

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

Parameters

Returns


ne

[Source]

Return false on a successful match, true otherwise.

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

Parameters

Returns


apply

[Source]

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 = 0)
: Match ref^ ?

Parameters

Returns


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

[Source]

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 = 0,
  global: Bool val = false)
: A^ ?

Parameters

Returns

  • A^ ?

split

[Source]

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

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

Parameters

Returns


index

[Source]

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

[Source]

Free the underlying PCRE2 data.

fun ref dispose()
: None val

Returns