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
+11.1k Golang : How to determine a prime number?
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+6.9k Nginx : Password protect a directory/folder
+18.4k Golang : Read binary file into memory
+10.6k Golang : How to delete element(data) from map ?
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+6.1k Golang : Debug with Godebug
+25.5k Golang : Generate MD5 checksum of a file
+18.4k Golang : How to remove certain lines from a file
+22.8k Golang : untar or extract tar ball archive example
+8.4k Golang : Ackermann function example
+4.7k Javascript : Access JSON data example