Skip to content

Commit 62d2caf

Browse files
committed
Reto #16 - go
1 parent 3cbd492 commit 62d2caf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"regexp"
6+
)
7+
8+
func main() {
9+
fmt.Printf("%v\n", ExtractNumber("There are 3 apples, 5 oranges, and 12 bananas."))
10+
}
11+
12+
func ExtractNumber(word string) []string {
13+
pattern := `\d+`
14+
re := regexp.MustCompile(pattern)
15+
return re.FindAllString(word, -1)
16+
}

0 commit comments

Comments
 (0)