-
-
Save zeffii/8980969 to your computer and use it in GitHub Desktop.
find index of last occurrence of token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bla = "qweronoquenr\n2424onounwerwer342342\nerw523535\n3534" | |
find_index_of_last = (instr, token) -> | |
return null if not (token in instr) | |
idx_shift = -1 | |
while true | |
fd = instr.indexOf(token, idx_shift+1) | |
if fd == -1 | |
return idx_shift | |
idx_shift = fd | |
m = find_index_of_last(bla, "\n") | |
console.log(m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment