Golang regexp.MustCompile() function example
package regexp
Golang regexp.MustCompile() function usage example.
package main
import (
"fmt"
"regexp"
)
func main() {
// regular expression pattern
regE := regexp.MustCompile("/oid/([\\d]+)/")
// simulate a search
// first convert string to byte for Find() function
searchByte := []byte("/oid/1/")
matchSlice := regE.Find(searchByte)
fmt.Printf("%s \n", matchSlice)
}
References :
https://www.socketloop.com/tutorials/golang-regular-expression-find-string-example
Advertisement
Something interesting
Tutorials
+9.5k Mac OSX : Get a process/daemon status information
+9.9k Golang : Check if user agent is a robot or crawler example
+8.4k Golang : Ackermann function example
+12.1k Golang : Pagination with go-paginator configuration example
+7k Golang : Find the shortest line of text example
+12.4k Elastic Search : Return all records (higher than default 10)
+11.2k Golang : How to pipe input data to executing child process?
+6.6k Golang : Warp text string by number of characters or runes example
+21.4k Curl usage examples with Golang
+9.7k Golang : interface - when and where to use examples
+7.1k Golang : Array mapping with Interface
+11.6k Golang : Surveillance with web camera and OpenCV