Elm Exactly
Results / elm-regex /

RegexIssue13FindStopsAtEmptyMatchTest

Tags:elm19-bug

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/regex#13

`Regex.find` stops at the first empty match instead of moving past it.

<https://github.com/elm/regex/issues/13>

`Regex.find ([a-z0-9]*)` on "simon er en" returns only "simon" in Elm 0.19.1 (elm/regex 1.0.0):
`_Regex_findAtMost` breaks out of its loop when `lastIndex` does not advance. JavaScript
(`"simon er en".match(/([a-z0-9]*)/g)`) finds `["simon","","er","","en",""]`; elm/regex is
documented as JavaScript regular expressions.

Results

elm-0.19.1

failran in 52 ms
Missing pattern: matches: ["simon","","er","","en",""]
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
matches: ["simon"]

elm-0.19.2

failran in 45 ms
Missing pattern: matches: ["simon","","er","","en",""]
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
matches: ["simon"]

elm-0.19.3

failran in 62 ms
Missing pattern: matches: ["simon","","er","","en",""]
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
matches: ["simon"]

lamdera-1.5.0

failran in 66 ms
Missing pattern: matches: ["simon","","er","","en",""]
--- output ---
matches: ["simon"]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module RegexIssue13FindStopsAtEmptyMatchTest exposing (main)
{-| `Regex.find` stops at the first empty match instead of moving past it.
<https://github.com/elm/regex/issues/13>
`Regex.find ([a-z0-9]*)` on "simon er en" returns only "simon" in Elm 0.19.1 (elm/regex 1.0.0):
`_Regex_findAtMost` breaks out of its loop when `lastIndex` does not advance. JavaScript
(`"simon er en".match(/([a-z0-9]*)/g)`) finds `["simon","","er","","en",""]`; elm/regex is
documented as JavaScript regular expressions.
-}
-- TAGS: elm19-bug
-- CHECK: matches: ["simon","","er","","en",""]
import Html exposing (text)
import Regex
main =
let
re =
Maybe.withDefault Regex.never (Regex.fromString "([a-z0-9]*)")
_ =
Debug.log "matches" (List.map .match (Regex.find re "simon er en"))
in
text "done"