andre-dietrich / elm-random-regex / Random.Regex

This library helps you generate random strings from regular expressions.

It is not tested yet, but in most cases it works. What is missing so far are assertions and back references.

Tested regular expressions:

ascii : String -> Result String (Random.Generator String)

Create a generator that produces ASCII strings based on a regular expression. Infinty is set to max 250, if you are using modifiers such as * or +. It is a shortcut for function generate.

generate : Encoding -> Basics.Int -> String -> Result String (Random.Generator String)

Create a generator that produces strings based on regular expressions.

generate ASCII 200 "a-z*" of
    Ok result ->
        ( model, Random.generate GenResult result )

    Err msg ->
        ( { model | result = msg }, Cmd.none )

unicode : String -> Result String (Random.Generator String)

Create a generator that produces UNICODE strings based on a regular expression. Infinty is set to max 250, if you are using modifiers such as * or +. It is a shortcut for function generate.


type Encoding
    = ASCII
    | UNICODE

Encoding defines the type of random characters to generate, for example for the . dot operator.

- `ASCII` : will generate values between 0 and 255
- `UNICODE` : will generate 16 bit values