Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Output:
- :: word
- hello my_name waat aha-ha --hi
- ::
- 0 5
- 6 8
- 9 13
- 14 18
- 19 25
- 26 30
- --hello--
- --my--
- --name--
- --waat--
- --aha-ha--
- ----hi--
- main:
- package main
- import "client_side/cuda"
- import "fmt"
- func main() {
- word:= "hello my_name waat aha-ha --hi"
- fmt.Printf(":: word \n%s\n::",word)
- cuda.GetWordIndexes(word)
- }
- cuda:
- func GetWordIndexes (entry string) (indexes []int) {
- reg:=regexp.MustCompile("[[:alnum:]-]+")
- match:= reg.FindAllString(entry, -1)
- match_indexes := reg.FindAllStringIndex(entry, -1)
- for i := range match_indexes{
- fmt.Printf("\n%d %d\n",match_indexes[i][0],match_indexes[i][1])
- }
- for i := range match {
- fmt.Printf("\n--%s--\n",match[i])
- }
- return indexes
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement