123456789101112131415161718 |
- package main
- import "regexp"
- // Find all the words in a string
- // return [][2]int of index,length
- func find_words(text string) [][]int {
- word, _ := regexp.Compile("([A-Za-z]+)")
- return word.FindAllStringIndex(text, -1)
- }
- // int version of Abs
- func Abs(x int) int {
- if x < 0 {
- return -x
- }
- return x
- }
|