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

Partial matching a string against a regex #836

Closed
sassanh opened this Issue Mar 3, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@sassanh

sassanh commented Mar 3, 2017

Suppose that I have this regular expression: /abcd/ Suppose that I want to check the user input against that regex and disallow entering invalid characters in the input. When user inputs "ab", it fails as an match for the regex, but I can't disallow entering "a" and then "b" as user can't enter all 4 characters at once (except for copy/paste). So what I need here is a partial match which checks if an incomplete string can be potentially a match for a regex.

Java has something for this purpose: .hitEnd() (described here http://glaforge.appspot.com/article/incomplete-string-regex-matching) python doesn't do it natively but has this package that does the job: https://pypi.python.org/pypi/regex.

I didn't find any solution for it in js. It's been asked years ago: http://stackoverflow.com/questions/9060979/javascript-regex-partial-match and even before that: http://stackoverflow.com/questions/416425/check-if-string-is-a-prefix-of-a-javascript-regexp
And I asked it here again: https://stackoverflow.com/questions/42461651/partial-matching-a-string-against-a-regex and still no answer.

I don't know where should I suggest this feature request. Please let me know if this is wrong place to ask for it and tell me where should I ask it instead.

@bakkot

This comment has been minimized.

Show comment
Hide comment
@bakkot

bakkot Mar 3, 2017

Contributor

See CONTRIBUTING.md. Feature requests should be made to esdiscuss.

Contributor

bakkot commented Mar 3, 2017

See CONTRIBUTING.md. Feature requests should be made to esdiscuss.

@bakkot bakkot closed this Mar 3, 2017

@bakkot

This comment has been minimized.

Show comment
Hide comment
@bakkot

bakkot Mar 3, 2017

Contributor

That said, on second glance it looks like this might be a better feature request for a library like XRegExp.

Contributor

bakkot commented Mar 3, 2017

That said, on second glance it looks like this might be a better feature request for a library like XRegExp.

@sassanh

This comment has been minimized.

Show comment
Hide comment
@sassanh

sassanh Mar 3, 2017

Thanks for info.

sassanh commented Mar 3, 2017

Thanks for info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment