Skip to content

regexp-tree does not optimize (\.(?!$)|$))$ #259

Open
@kurtextrem

Description

@kurtextrem

Coming from this SO post: https://stackoverflow.com/a/36760050
The regex

^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$

got optimized (by hand) to:

^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$

so, partbefore(\.(?!$)|$))$ can be expressed as (partbefore\.?\b)$, avoiding the negative look-ahead, making the regex smaller.

Maybe worth adding as optimization?

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