mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
feat(utils): Add GetTrimIndex
This commit is contained in:
parent
46a50c16a8
commit
e8fe8d1a96
@ -1,7 +1,22 @@
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IndexOffset(s string, search string, start int) int {
|
||||
return strings.Index(s[start:], search) + start
|
||||
}
|
||||
|
||||
var trimIndexPattern = regexp.MustCompile(`^\s+(.+?)\s+`)
|
||||
|
||||
func GetTrimIndex(s string) []int {
|
||||
indexes := trimIndexPattern.FindStringSubmatchIndex(s)
|
||||
|
||||
if indexes == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return indexes[2:4]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user