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
+6.9k Golang : Calculate BMI and risk category
+34.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+5.2k Golang : The Tao of importing package
+12.1k Golang : convert(cast) string to integer value
+15.7k Golang : Get checkbox or extract multipart form data value example
+5k Python : Convert(cast) bytes to string example
+5.7k Golang : Error handling methods
+5.4k Python : Delay with time.sleep() function example
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+15.6k Golang : rune literal not terminated error
+16.3k Golang : convert string or integer to big.Int type
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?