Skip to content

Instantly share code, notes, and snippets.

@patio11
Created May 29, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patio11/efc421680aa2fd49c761 to your computer and use it in GitHub Desktop.
Save patio11/efc421680aa2fd49c761 to your computer and use it in GitHub Desktop.
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