Pudu programming language
Menu
API reference

Std.Regex.compile

1 declaration

fn

compile: Str -> Result[Std.Regex.Regex, Std.Regex.RegexError]

This is a callable function.

What it does

Compile a pattern, or say where it stopped making sense.

The whole pattern is read here rather than at each use, so a pattern used in

a loop is examined once. A caller holding a Regex holds something that is

known to be a pattern; nothing below can fail for a reason of syntax.

A pattern written as a Pudu literal meets one rule of the language first:

{ and } open and close an interpolation, so a counted repetition is

written "a\{3\}" and a backslash the pattern should see is written \\.

A pattern read from a file or a form needs none of that.

Read the signature

  • The text after the name is the type checked by Pudu.
  • Read arrows from left to right: inputs come first, and the final type is returned.
  • Names inside [ ] are type arguments, such as the item type held by a collection.
  • Result makes success and recoverable failure part of the function's type.

Back to Std.RegexSearch related declarations