initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
21
joplin notion extension/Web Development/Go/regex.md
Normal file
21
joplin notion extension/Web Development/Go/regex.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
|
||||
|
||||
```
|
||||
Loading…
Reference in a new issue