Skip to content

ordering of match alternatives matters #327

@faceprint

Description

@faceprint

In the example regex (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il|e|y|ust|tember|ober|ember)? +\d{1,2} +\d{4} (which I acknowledge is sloppy since it matches Febtember) having the e alternative before ember causes it not to match November or December as a month. I don't know if this is strictly "correct" behavior, but this works in every other regex engine I've tried.

The workaround of (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il|ust|tember|ober|ember|e|y)? +\\d{1,2} +\\d{4} does work in CTRE.

regex101 link

godbolt link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions