12345678910111213141516171819202122232425262728 |
- package local_objs
- import "regexp"
- func GetObjFromText(text string) []string {
- rule := "img src=\".*?\""
- reg, _ := regexp.Compile(rule)
- result := reg.FindAllStringSubmatch(text, -1)
- if len(result) == 0 {
- return []string{}
- }
- ret := []string{}
- key := "img src=\""
- keyLength := len(key)
- for _, array := range result {
- if len(array) == 0 {
- continue
- }
- str := array[0]
- if len(str) < keyLength+1 {
- continue
- }
- str = str[keyLength:]
- str = str[:len(str)-1]
- ret = append(ret, str)
- }
- return ret
- }
|