21 lines
No EOL
532 B
Markdown
21 lines
No EOL
532 B
Markdown
regex
|
|
https://gobyexample.com/regular-expressions
|
|

|
|
|
|
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
|
|
|
|
|
|
``` |