Created
September 18, 2017 17:34
-
-
Save eloycoto/455b5bff957e96a8a9f48fe608a67d47 to your computer and use it in GitHub Desktop.
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() { | |
// Compile the expression once, usually at init time. | |
// Use raw strings to avoid having to quote the backslashes. | |
var validID = regexp.MustCompile(`^jsonpath\=(.*)`) | |
fmt.Println(validID.MatchString("jsonpath='{.items[?(@.spec.nodeName == \"MERDA\")].metadata.name}'")) | |
fmt.Println(validID.ReplaceAllString("jsonpath='{.items[?(@.spec.nodeName == \"MERDA\")].metadata.name}'", "$1")) | |
fmt.Println(validID.MatchString("eve[7]")) | |
fmt.Println(validID.MatchString("Job[48]")) | |
fmt.Println(validID.MatchString("snakey")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment