Skip to content

Regex.Matches no longer returns the empty trailing match for the .* pattern #42392

Closed

Description

@slozier

Description

Regex.Matches no longer returns the empty trailing match for the .* pattern. I expected the following to succeed:

Debug.Assert(new Regex(".*").Matches("abc").Select(x => x.Value).SequenceEqual(new List<string> { "abc", "" }));

I'm not sure if this should be considered a bug or if it's an intentional change. For comparison, Python also include the empty entry in its result set (re.findall(".*", "") == ['abc', '']).

Configuration

.NET SDK (reflecting any global.json):
Version: 5.0.100-rc.1.20452.10
Commit: 473d1b592e

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\

Host (useful for support):
Version: 5.0.0-rc.1.20451.14
Commit: 38017c3

Regression?

This works in .NET Core 3.1 and .NET Framework.

Activity

  1. added
    untriaged
    on Sep 17, 2020
  2. stephentoub commented on Sep 17, 2020

    @stephentoub
    Member

    This is the same root cause as #42390. Fixing that will fix this, too.

  3. self-assigned this
    on Sep 17, 2020
  4. removed
    untriaged
    on Sep 17, 2020
  5. added this to the 5.0.0 milestone on Sep 17, 2020
  6. jeffhandley commented on Sep 19, 2020

    @jeffhandley
    Member

    Fixed in #42408 (master) and #42409 (release/5.0)

  7. ghost locked as resolved and limited conversation to collaborators on Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions