FindStringIndex returns a two-element slice of integers defining the location of the leftmost match in s. The match is at s[loc[0]:loc[1]]. Returns nil if no match is found. Example: re := coregex.MustCompile(`\d+`) loc := re.FindStringIndex("age: 42") println(loc[0], loc[1]) // 5, 7
(s string)
| 358 | // loc := re.FindStringIndex("age: 42") |
| 359 | // println(loc[0], loc[1]) // 5, 7 |
| 360 | func (r *Regex) FindStringIndex(s string) []int { |
| 361 | start, end, found := r.engine.FindIndices(stringToBytes(s)) |
| 362 | if !found { |
| 363 | return nil |
| 364 | } |
| 365 | return []int{start, end} |
| 366 | } |
| 367 | |
| 368 | // FindAll returns a slice of all successive matches of the pattern in b. |
| 369 | // If n > 0, it returns at most n matches. If n <= 0, it returns all matches. |