Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
raxod502 opened this issue May 12, 2020 · 0 comments
Open

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

raxod502 opened this issue May 12, 2020 · 0 comments

Comments

@raxod502
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant