Created
March 11, 2013 11:45
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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