Skip to content

Instantly share code, notes, and snippets.

@cihangir
Created June 18, 2013 06:33
Show Gist options
  • Save cihangir/5803089 to your computer and use it in GitHub Desktop.
Save cihangir/5803089 to your computer and use it in GitHub Desktop.
Go lang Regex
package main
import (
"fmt"
"regexp"
)
func main() {
//re := regexp.MustCompile("a(x*)b")
re := regexp.MustCompile("(buffal|tomat|potat)o$")
fmt.Println(re.ReplaceAllString("tomato", "${1}oes"))
fmt.Println(re.ReplaceAllString("-ab-axxb-", "T"))
fmt.Println(re.ReplaceAllString("-ab-axxb-", "$1"))
fmt.Println(re.ReplaceAllString("-ab-axxb-", "$1W"))
fmt.Println(re.ReplaceAllString("-ab-axxb-", "${1}W"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment