RegexSplitTest
`Regex.split` cuts a string at every match and drops the matched text. Splitting `"abc123def456ghi"` on `[0-9]+` gives the three letter runs between the digit runs.
Results
elm-0.19.1
passran in 71 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. split1: ["abc","def","ghi"]
elm-0.19.2
passran in 64 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. split1: ["abc","def","ghi"]
elm-0.19.3
passran in 52 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. split1: ["abc","def","ghi"]
lamdera-1.5.0
passran in 73 msOutput
split1: ["abc","def","ghi"]
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-regex/RegexSplitTest] in its title.
Source
The -- CHECK: lines give the expected output.
module RegexSplitTest exposing (main)
{-| `Regex.split` cuts a string at every match and drops the matched text.
Splitting `"abc123def456ghi"` on `[0-9]+` gives the three letter runs between
the digit runs.
-}
-- CHECK: split1: ["abc","def","ghi"]
import Html exposing (text)
import Regex
main =
let
regex = Maybe.withDefault Regex.never (Regex.fromString "[0-9]+")
_ = Debug.log "split1" (Regex.split regex "abc123def456ghi")
in
text "done"