Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

According to the debugger at http://regex101.com/:

  /.*(\d)/
- Searches right-to-left, backtracking until it finds the match.

  /(\d)\D*$/
- Searches left-to-right, going forward a step, backtrack, forward, backtrack, until it finds a match.

If you're looking for a match toward the end of a string, the .* version will be faster.



Wow, regex101.com is very nice, but I never would have noticed that debugger pane if I hadn't gone looking for it after your comment. Incredibly useful tool.




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

Search: