Skip to content

Instantly share code, notes, and snippets.

@jemygraw
Created January 17, 2017 06:39
Show Gist options
  • Save jemygraw/8f77b9c392ae2283c7b1b4d5291818b9 to your computer and use it in GitHub Desktop.
Save jemygraw/8f77b9c392ae2283c7b1b4d5291818b9 to your computer and use it in GitHub Desktop.
golang regexp group
package main
import (
"fmt"
"regexp"
)
func main() {
rule := `^/upload/photo/(\w+)/(\w+)/(\w+)/(70|60|48|32|16|80|150)\_(.*)$`
str := "/upload/photo/0/0/0/70_u57313833790062233714.jpg"
r := regexp.MustCompile(rule)
m := r.FindAllStringSubmatch(str, -1)
fmt.Println(m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment