parseViews check search has views or not
(query *string)
| 249 | |
| 250 | // parseViews check search has views or not |
| 251 | func (sp *SearchParser) parseViews(query *string) (views int) { |
| 252 | var ( |
| 253 | q = *query |
| 254 | expr = `views:(\d+)` |
| 255 | ) |
| 256 | views = -1 |
| 257 | |
| 258 | re := regexp.MustCompile(expr) |
| 259 | res := re.FindStringSubmatch(q) |
| 260 | if len(res) > 1 { |
| 261 | views = converter.StringToInt(res[1]) |
| 262 | q = re.ReplaceAllString(q, "") |
| 263 | } |
| 264 | *query = strings.TrimSpace(q) |
| 265 | return |
| 266 | } |
| 267 | |
| 268 | // parseAnswers check whether specified answer count for question |
| 269 | func (sp *SearchParser) parseAnswers(query *string) (answers int) { |
no test coverage detected