Advertisement
Guest User

dss3232

a guest
Nov 30th, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.82 KB | None | 0 0
  1. Output:
  2.  
  3. :: word
  4. hello my_name waat aha-ha --hi
  5. ::
  6. 0 5
  7.  
  8. 6 8
  9.  
  10. 9 13
  11.  
  12. 14 18
  13.  
  14. 19 25
  15.  
  16. 26 30
  17.  
  18. --hello--
  19.  
  20. --my--
  21.  
  22. --name--
  23.  
  24. --waat--
  25.  
  26. --aha-ha--
  27.  
  28. ----hi--
  29.  
  30.  
  31.  
  32.  
  33.  
  34. main:
  35.  
  36. package main
  37. import "client_side/cuda"
  38. import "fmt"
  39.  
  40.  
  41. func main() {
  42.  
  43.    
  44.     word:= "hello my_name waat aha-ha --hi"
  45.     fmt.Printf(":: word \n%s\n::",word)
  46.     cuda.GetWordIndexes(word)
  47.  
  48. }
  49.  
  50.  
  51. cuda:
  52.  
  53. func GetWordIndexes (entry string) (indexes []int) {
  54.  
  55.     reg:=regexp.MustCompile("[[:alnum:]-]+")
  56.     match:= reg.FindAllString(entry, -1)
  57.     match_indexes := reg.FindAllStringIndex(entry, -1)
  58.     for i := range match_indexes{
  59.         fmt.Printf("\n%d %d\n",match_indexes[i][0],match_indexes[i][1])
  60.     }
  61.     for i := range match {
  62.         fmt.Printf("\n--%s--\n",match[i])
  63.  
  64.     }
  65.     return indexes
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement