Golang regexp.Compile() function and FindString() example
package regexp
Golang regexp.Compile() function and FindString() usage example.
package main
import (
"fmt"
"regexp"
)
func main() {
// regular expression pattern
re, err := regexp.Compile("a(|b)")
if err != nil {
fmt.Println(err)
}
s := re.FindString("ab")
fmt.Println("First match : ", s)
}
Output :
First match : a
Advertisement
Something interesting
Tutorials
+9.6k Golang : Validate IPv6 example
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+9.4k Golang : Apply Histogram Equalization to color images
+6.6k Golang : How to determine if request or crawl is from Google robots
+19.1k Mac OSX : Homebrew and Golang
+7.8k Golang : Reverse a string with unicode
+8.1k Golang : Append and add item in slice
+10.1k Golang : Get login name from environment and prompt for password
+43.3k Golang : Convert []byte to image
+5.4k Golang : Reclaim memory occupied by make() example
+27.6k PHP : Convert(cast) string to bigInt
+8.9k Golang : Sort lines of text example