Skip to content

No way to efficiently match at beginning of string? #12

@raxod502

Description

@raxod502

I have a long string and need to check if a regex matches at the beginning of it (I am writing a lexer). Unfortunately, regex-tdfa does not appear to stop searching once it is clear that there is no match. For example, the following code snippet takes several seconds to evaluate on my machine:

Text.Regex.TDFA> replicate 100000000 'f' =~~ "\\`g" :: Maybe String
Nothing

However, the code snippet should evaluate instantly, because as soon as the first character is inspected it is clear that the regex does not match at the beginning of the string. Given this behavior, it seems impossible to use regex-tdfa to performantly match a regex at the beginning of a string. Is there a special-purpose function for this that I have missed?

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