Skip to content

Unexpected behavior with .NET's (9.0 specific) Regex engine when matching emoji. #119593

@cheblin

Description

@cheblin

Hello,

I've noticed some unexpected behavior with .NET's (9.0 specific) Regex engine when matching emoji. I'm trying to find all characters that belong to the "Symbol, Other" (So) Unicode category.

When I run the following code, the result is 0, but I would expect it to be 1, since the hotdog emoji (🌭) is a symbol.

Console.WriteLine(new Regex(@"\p{So}").Matches("🌭").Count); 
// Output: 0

Could you explain why this happens and what the correct way to match such characters would be?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions