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

String.Extra.rightOf does not return anything past line breaks. #65

Open
RalfNorthman opened this issue Aug 28, 2024 · 0 comments · May be fixed by #75
Open

String.Extra.rightOf does not return anything past line breaks. #65

RalfNorthman opened this issue Aug 28, 2024 · 0 comments · May be fixed by #75
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@RalfNorthman
Copy link

Describe the bug
String.Extra.rightOf does not return anything past line breaks. Is this the expected behavior? It confused me at least.

To Reproduce
Steps to reproduce the behavior:

Check out this Ellie:
https://ellie-app.com/s5R3HsrPbhJa1

Code block for posterity:

module Main exposing (main)

import Browser
import Html exposing (Html, div, text)
import String.Extra

type alias Model =
    { input : String
    , rightOfResult : String
    , manualSplitResult : String
    }

init : Model
init =
    let
        input = "Header\r\n<needle>\r\nData1\r\nData2\r\nData3"
        rightOfResult = String.Extra.rightOf "<needle>" input
        manualSplitResult = 
            String.split "<needle>" input
                |> List.drop 1
                |> List.head
                |> Maybe.withDefault ""
                |> String.trimLeft
    in
    { input = input
    , rightOfResult = rightOfResult
    , manualSplitResult = manualSplitResult
    }

view : Model -> Html msg
view model =
    div []
        [ div [] [ text ("Input: " ++ model.input) ]
        , div [] [ text ("String.Extra.rightOf result: " ++ model.rightOfResult) ]
        , div [] [ text ("Manual split result: " ++ model.manualSplitResult) ]
        ]

main : Program () Model msg
main =
    Browser.sandbox
        { init = init
        , view = view
        , update = \_ model -> model
        }

Expected behavior
I expect rightOf to return everything after the match, regardless of line breaks.

Additional context

The siblings of rightOf probably have the same issue.

I think this behavior could be inherited from the underlying regex package with the use of $ which matches on line end. I have not checked if this is the case though.

@RalfNorthman RalfNorthman added the bug Something isn't working label Aug 28, 2024
@gampleman gampleman added help wanted Extra attention is needed good first issue Good for newcomers labels Aug 28, 2024
@gampleman gampleman linked a pull request Mar 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants