Archived
Template
1
0
This repository has been archived on 2023-12-20. You can view files and clone it, but cannot push or open issues or pull requests.
Files
golang-base-project/text/segment.go
Markus Tenghamn e586933a6b Improves documentation (#13)
* Documents all env variables and adds an example project

* Adds godoc comments

* Fixed package naming issue
2022-01-09 14:42:03 +01:00

18 lines
382 B
Go

package text
import "strings"
// BetweenStrings returns a string between the starting and ending string or an empty string if none could be found
func BetweenStrings(str string, start string, end string) (result string) {
s := strings.Index(str, start)
if s == -1 {
return
}
s += len(start)
e := strings.Index(str[s:], end)
if e == -1 {
return
}
return str[s : s+e]
}