joplin-notes/joplin notion extension/Web Development/Go/regex.md
2026-11-04 00:33:23 +05:30

532 B

regex https://gobyexample.com/regular-expressions Go by Example_ Regular Expressions.pdf

for url

func DoesContainURL(str string) (bool, error) {
	// regex := `/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/`
	regex := `https?://[^\s]+`

	res, err := regexp.MatchString(regex, str)

	fmt.Println("does: ", res)

	return res, err
}

DoesContainURL("sd http://yourrt.com/122 sads") // true