Created
June 18, 2013 06:33
-
-
Save cihangir/5803089 to your computer and use it in GitHub Desktop.
Go lang Regex
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
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