package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)^(?:https?:\/\/)?(?:www\.)?[\d\w\.-]+(?:\.|:)(?:[a-z\.]{2,6}|\d+)\/?.*$`)
var str = `https://regex101.com/
https://www.variables.sh/complex-regular-expression-examples
https://search.brave.com/search?q=regex+challenges&source=desktop
https://web.whatsapp.com/
https://www.youtube.com/watch?v=fc_RvxTtIwc
https://text-auditor.netlify.app/
https://github.com/Dashrath-Sharma
http://github.com/Dashrath-Sharma
https://onecompiler.com/javascript/3zqzyu2g4
http://localhost:3000/
https://www.codingame.com/clashofcode/clash/report/3342454a92e4c660d772438bac8b2ef73de3c8f
https://react.dev/learn/thinking-in-react
https://dapp-world.com/course/introduction-to-solidity-Ynws/working-of-traditional-dapps-compared-to-dapps/reading
http://www.google.com
https://www.google.com
http://google.com
https://google.com
http://www.google.com/
https://www.google.com/
http://google.com/
https://google.com/
http://www.google.com/index.html
https://www.google.com/index.html
http://google.com/index.html
https://google.com/index.html
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/