Hacker News new | past | comments | ask | show | jobs | submit login
Which position in the string caused the regular expression to fail? (stackoverflow.com)
1 point by joeframbach on May 24, 2014 | hide | past | favorite | 1 comment



I think there is a simple and obvious way to define that position.

"the longest prefix string of the input where a suffix exists that would cause the regex match to succeed" is well-defined and easily determined (by looking at the characters a normal regex engine inspects during matching).

The character after that should be the asked for offset. That could be one more than the length of the string, for example when looking for a digit in a string that doesn't contain one.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: