Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: capture groups should be able to match empty string #5

Open
evashort opened this issue Aug 27, 2018 · 1 comment
Open

Comments

@evashort
Copy link

evashort commented Aug 27, 2018

SSCCE:

module Main exposing (main)

import Browser
import Html exposing (Html, text)
import Regex

view : Html Never
view =
    text -- first submatch should be Just "" instead of Nothing
        ( Debug.toString
            ( Regex.find
                ( Maybe.withDefault
                    Regex.never
                    (Regex.fromString "(.*)")
                )
                ""
            )
        )

main : Program () () Never
main =
    Browser.sandbox
        { init = ()
        , view = always view
        , update = always identity
        }
@kkos
Copy link

kkos commented Aug 31, 2018

The correction is as follows.
But I can't check it because I don't know how to run the test program with Elm native code in my local project on Elm 0.19.

--- a/src/Elm/Kernel/Regex.js
+++ b/src/Elm/Kernel/Regex.js
@@ -77,7 +77,7 @@ var _Regex_replaceAtMost = F4(function(n, re, replacer, string)
                while (i > 0)
                {
                        var submatch = arguments[i];
-                       submatches[--i] = submatch
+                       submatches[--i] = submatch != null
                                ? __Maybe_Just(submatch)
                                : __Maybe_Nothing;
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants