Created
May 29, 2015 17:29
-
-
Save patio11/efc421680aa2fd49c761 to your computer and use it in GitHub Desktop.
A comparison of golang and Ruby regular expression use
This file contains 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
#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