Partial matching a string against a regex
sassanh at gmail.com
Fri Mar 3 21:16:32 UTC 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.
And I asked it here again: https://stackoverflow.com/questions/42461651/partial-matching-a-string-against-a-regex and still no answer.
I’ve created an issue requesting this feature on xregexp. But I think it’d be great if native js regex engine could handle this it.
More information about the es-discuss