MCPcopy Index your code
hub / github.com/apache/answer / parseAnswers

Method parseAnswers

internal/service/search_parser/search_parser.go:269–285  ·  view source on GitHub ↗

parseAnswers check whether specified answer count for question

(query *string)

Source from the content-addressed store, hash-verified

267
268// parseAnswers check whether specified answer count for question
269func (sp *SearchParser) parseAnswers(query *string) (answers int) {
270 var (
271 q = *query
272 expr = `answers:(\d+)`
273 )
274 answers = -1
275
276 re := regexp.MustCompile(expr)
277 res := re.FindStringSubmatch(q)
278 if len(res) > 1 {
279 answers = converter.StringToInt(res[1])
280 q = re.ReplaceAllString(q, "")
281 }
282
283 *query = strings.TrimSpace(q)
284 return
285}
286
287// parseAccepted check the search is limit accepted answer or not
288func (sp *SearchParser) parseAccepted(query *string) (accepted bool) {

Callers 1

ParseStructureMethod · 0.95

Calls 1

StringToIntFunction · 0.92

Tested by

no test coverage detected