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.6k Golang : Embedded or data bundling example
+8.8k Golang : Random integer with rand.Seed() within a given range
+5.4k Unix/Linux/MacOSx : How to remove an environment variable ?
+7.3k Golang : alternative to os.Exit() function
+5.5k Golang : Display advertisement images or strings on random order
+10.3k Golang : Detect number of faces or vehicles in a photo
+7.5k Golang : How to stop user from directly running an executable file?
+18.8k Golang : Delete duplicate items from a slice/array
+21.8k Golang : How to reverse slice or array elements order
+5.1k Golang : Check if a word is countable or not
+9.4k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+10.5k Generate Random number with math/rand in Go