Skip to content

Split with empty pattern returns extra empty strings #90

@kolkov

Description

@kolkov

Bug Description

re.Split("", "abc") returns extra empty strings at the start and end compared to stdlib.

Reproduction

// stdlib
re := regexp.MustCompile("")
re.Split("abc", -1)  // returns ["a", "b", "c"]

// coregex
re := coregex.MustCompile("")
re.Split("abc", -1)  // returns ["", "a", "b", "c", ""]

Expected vs Actual

Engine Result
stdlib ["a", "b", "c"]
coregex ["", "a", "b", "c", ""]

Root Cause

The Split implementation does not handle empty pattern matching correctly at boundaries.

Impact

Applications using Split("", str) to split into characters get unexpected empty strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions