summaryrefslogtreecommitdiff
path: root/utils/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/utils.go')
-rw-r--r--utils/utils.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/utils/utils.go b/utils/utils.go
index e4610c97c..e3cb121f4 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -10,6 +10,7 @@ import (
"os/exec"
"path"
"path/filepath"
+ "regexp"
"strings"
"github.com/mssola/user_agent"
@@ -321,10 +322,15 @@ func GetHostnameFromURL(u url.URL) string {
// GetHostnameFromURLString will return the hostname component from a URL object.
func GetHostnameFromURLString(s string) string {
u, err := url.Parse(s)
-
if err != nil {
return ""
}
return u.Host
}
+
+// GetHashtagsFromText returns all the #Hashtags from a string.
+func GetHashtagsFromText(text string) []string {
+ re := regexp.MustCompile(`#[a-zA-Z0-9_]+`)
+ return re.FindAllString(text, -1)
+}