parseWithin parse quotes within words like: "hello world"
(query *string)
| 197 | |
| 198 | // parseWithin parse quotes within words like: "hello world" |
| 199 | func (sp *SearchParser) parseWithin(query *string) (words []string) { |
| 200 | var ( |
| 201 | q = *query |
| 202 | expr = `(?U)(".+")` |
| 203 | ) |
| 204 | re := regexp.MustCompile(expr) |
| 205 | matches := re.FindAllStringSubmatch(q, -1) |
| 206 | words = []string{} |
| 207 | for _, match := range matches { |
| 208 | if len(match[1]) == 0 { |
| 209 | continue |
| 210 | } |
| 211 | words = append(words, match[1]) |
| 212 | } |
| 213 | q = re.ReplaceAllString(q, "") |
| 214 | *query = strings.TrimSpace(q) |
| 215 | return |
| 216 | } |
| 217 | |
| 218 | // parseNotAccepted return the question has not accepted the answer |
| 219 | func (sp *SearchParser) parseNotAccepted(query *string) (notAccepted bool) { |