parseVotes return the votes of search query
(query *string)
| 178 | |
| 179 | // parseVotes return the votes of search query |
| 180 | func (sp *SearchParser) parseVotes(query *string) (votes int) { |
| 181 | var ( |
| 182 | expr = `score:(\d+)` |
| 183 | q = *query |
| 184 | ) |
| 185 | votes = -1 |
| 186 | |
| 187 | re := regexp.MustCompile(expr) |
| 188 | res := re.FindStringSubmatch(q) |
| 189 | if len(res) > 1 { |
| 190 | votes = converter.StringToInt(res[1]) |
| 191 | q = re.ReplaceAllString(q, "") |
| 192 | } |
| 193 | |
| 194 | *query = strings.TrimSpace(q) |
| 195 | return |
| 196 | } |
| 197 | |
| 198 | // parseWithin parse quotes within words like: "hello world" |
| 199 | func (sp *SearchParser) parseWithin(query *string) (words []string) { |
no test coverage detected