How to extract numbers from string with regular expression in Go

1 Answer

0 votes
package main 
  
import ( 
    "fmt"
    "regexp"
) 
  
func main() { 
    reg := regexp.MustCompile(`[-]?\d[\d]*[\]?[\d{2}]*`) 
  
    fmt.Println(reg.FindAllString("go 12 java 847 python 9815 golang 88 php", 3)) 
} 



/*
run:

[12 847 9815]

*/

 



answered Aug 4, 2020 by avibootz

Related questions

...