Elm Exactly
Results / elm-regex /

RegexContainsTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Regex.contains` reports whether a regex matches anywhere in a string.

The pattern `[0-9]+` is checked against a string with digits at its end, which
is `True`, and against one with no digits, which is `False`.

Results

elm-0.19.1

passran in 46 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
contains_yes: True
contains_no: False

elm-0.19.2

passran in 38 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
contains_yes: True
contains_no: False

elm-0.19.3

passran in 49 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
contains_yes: True
contains_no: False

lamdera-1.5.0

passran in 52 ms
Output
contains_yes: True
contains_no: False

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-regex/RegexContainsTest] in its title.

Source

The -- CHECK: lines give the expected output.

module RegexContainsTest exposing (main)
{-| `Regex.contains` reports whether a regex matches anywhere in a string.
The pattern `[0-9]+` is checked against a string with digits at its end, which
is `True`, and against one with no digits, which is `False`.
-}
-- CHECK: contains_yes: True
-- CHECK: contains_no: False
import Html exposing (text)
import Regex
main =
let
regex = Maybe.withDefault Regex.never (Regex.fromString "[0-9]+")
_ = Debug.log "contains_yes" (Regex.contains regex "abc123")
_ = Debug.log "contains_no" (Regex.contains regex "abcdef")
in
text "done"