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
+5.5k Golang : Stop goroutine without channel
+23.2k Golang : Print out struct values in string format
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+37.7k Golang : Comparing date or timestamp
+16.9k Golang : Read integer from file into array
+18.6k Golang : Find IP address from string
+6.9k How to let Facebook Login button redirect to a particular URL ?
+37.5k Golang : Converting a negative number to positive number
+39.2k Golang : How to read CSV file
+25.3k Golang : Convert uint value to string type