Last active
April 7, 2019 09:23
-
-
Save OrKoN/cbbf0d4032b4bf3ffc0125eeff845f8b to your computer and use it in GitHub Desktop.
String index of a substring with start index
This file contains hidden or 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
import "strings" | |
func indexAt(str, substr string, start int) int { | |
idx := strings.Index(str[start:], substr) | |
if idx == -1 { | |
return idx | |
} | |
return idx + start | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment