From 2ea54b9d1e382db8eeb4254dc637e7d04316d01e Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 1 Jun 2016 16:05:36 -0400 Subject: PLT-2283 Improved trimming of punctuation from hashtags and search terms (#3178) * Improved trimming of punctuation from hashtags and search terms * Separated punctuation regexes used for hashtags and for search terms --- model/utils.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'model/utils.go') diff --git a/model/utils.go b/model/utils.go index 443a34bc4..27093c096 100644 --- a/model/utils.go +++ b/model/utils.go @@ -315,10 +315,9 @@ func Etag(parts ...interface{}) string { } var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöüÄÖÜß_\-]*[A-Za-z0-9äöüÄÖÜß])$`) -var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\<>\-+=%^*|]+`) +var puncStart = regexp.MustCompile(`^[^\pL\d\s#]+`) var hashtagStart = regexp.MustCompile(`^#{2,}`) -var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`) -var puncEndWildcard = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^|]+$`) +var puncEnd = regexp.MustCompile(`[^\pL\d\s]+$`) func ParseHashtags(text string) (string, string) { words := strings.Fields(text) -- cgit v1.2.3-1-g7c22