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

When I want to use negative indices, I pipe the string through rev first, then do my cut, then rev again


That's the classic solution but blows up when using multibyte characters since rev just reads the bytes in each line in reverse.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: