Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A comparison of golang and Ruby regular expression use
#In Golang
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile("fo.?")
fmt.Printf("%q\n", re.FindString("seafood"))
fmt.Printf("%q\n", re.FindString("meat"))
}
#In Ruby
puts "seafood"[/fo.?/]
puts "meat"[/fo.?/]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment