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

21 lines
No EOL
532 B
Markdown

regex
https://gobyexample.com/regular-expressions
![Go by Example_ Regular Expressions.pdf](../../../_resources/Go%20by%20Example_%20Regular%20Expressions.pdf)
for url
```go
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
```