package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`"(user|from)_id":(-?\d+)`)
var str = `{"response":{"count":21854,"items":[{"id":228162,"body":"๐","user_id":136649652,"from_id":331639485,"date":1484581971,"read_state":1,"out":1,"random_id":0,"emoji":1},{"id":228161,"body":"๐","user_id":136649652,"from_id":136649652,"date":1484581970,"read_state":1,"out":0,"emoji":1},{"id":228160,"body":"ัััะพัะบะต*","user_id":136649652,"from_id":136649652,"date":1484581969,"read_state":1,"out":0},{"id":228159,"body":"ะั","user_id":136649652,"from_id":331639485,"date":1484581969,"read_state":1,"out":1,"random_id":0},{"id":228158,"body":"๐","user_id":136649652,"from_id":136649652,"date":1484581962,"read_state":1,"out":0,"emoji":1},{"id":228157,"body":"ะธะปะธ","user_id":136649652,"from_id":136649652,"date":1484581962,"read_state":1,"out":0},{"id":228154,"body":"ัั ","user_id":136649652,"from_id":136649652,"date":1484581935,"read_state":1,"out":0}`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/