I want to find all the numbers in a string with the following code:
re:=regexp.MustCompile("[0-9]+")
fmt.Println(re.FindAllString("abc123def", 0))
I also tried adding delimiters to the regular expression, using a positive number as the second parameter for FindAllString
, using only a string of numbers, such as "123" as the first parameter ...
But the way out is always []
I seem to have missed something about how regular expressions work in Go, but can't wrap their heads around it. Is the [0-9]+
expression invalid?
source
share