How to find index of substring with regular expression in Go

1 Answer

0 votes
package main 
  
import ( 
    "fmt"
    "regexp"
) 
  
func main() { 
    reg := regexp.MustCompile(`go`) 
  
    fmt.Println(reg.FindStringIndex("hava go c++ go php")) 
  
} 
   
     
/*
run:
     
[5 7]
     
*/

 



answered Aug 3, 2020 by avibootz

Related questions

3 answers 270 views
1 answer 185 views
1 answer 236 views
1 answer 223 views
1 answer 185 views
...