blog.golang.org/slices and blog.golang.org/strings -rob
On Sat, May 27, 2017 at 11:14 AM, <long.a...@gmail.com> wrote: > I find the method like: > > package main > > > import ( > "fmt" > "strings" > "unicode/utf8" > ) > > > func main() { > var str = "a/b/汉字/d/汉字" > var _, size = utf8.DecodeLastRuneInString(str) > // Does `str[0:len(str)-size]` have memory copy? > var i = strings.LastIndex(str[0:len(str)-size], "/汉字") > fmt.Println(i) > } > > > > But I don't know if str[0:len(str)-size] if copy the string? If the code > will copy the string, I will covert the string to []byte first. Because I > need several times check for the str. > Where I can find some article about that(str copy)? > > > On Friday, May 26, 2017 at 10:45:09 PM UTC+8, long...@gmail.com wrote: >> >> var str = "a/b/c/d/c" >> // I want remove last chracter from str >> var strRunes = []rune(str) >> var newStrRunes = strRunes[0 : len(strRunes)-1] >> // then I want get last index of chracters `/c`, I need >> convert to string back!??? >> strings.LastIndex(string(newStrRunes), "/c") >> // Does there have a method that LastIndex(rs []rune, s >> string) >> >> Thanks for your help! >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.