Skip to content

Instantly share code, notes, and snippets.

@physacco
Created March 11, 2013 11:45
Show Gist options
  • Save physacco/5133674 to your computer and use it in GitHub Desktop.
Save physacco/5133674 to your computer and use it in GitHub Desktop.
This is a basic example of the regexp package in go's stdlib.
package main
import (
"fmt"
"regexp"
)
func main() {
str := "Ruby 2.0 is the 2nd major release of Ruby"
re, err := regexp.Compile("[.\\d]+")
if err != nil {
panic(err)
}
fmt.Println(re.FindAll([]byte(str), -1))
fmt.Println(re.FindAllIndex([]byte(str), -1))
fmt.Println(re.FindAllString(str, -1))
fmt.Println(re.FindAllStringIndex(str, -1))
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment