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
+19.1k Mac OSX : Homebrew and Golang
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+29.1k Golang : Get first few and last few characters from string
+25.3k Golang : Convert uint value to string type
+31.5k Golang : bufio.NewReader.ReadLine to read file line by line
+8.1k Golang : Append and add item in slice
+7.8k Swift : Convert (cast) String to Double
+10.1k Golang : Compare files modify date example
+8.8k Golang : Random integer with rand.Seed() within a given range
+17.1k Golang : Capture stdout of a child process and act according to the result
+7.1k Golang : Get environment variable