summaryrefslogtreecommitdiff
path: root/src/pkg/strings/strings.go
diff options
context:
space:
mode:
authorSteve Newman <devnull@localhost>2009-06-09 10:58:58 -0700
committerSteve Newman <devnull@localhost>2009-06-09 10:58:58 -0700
commitd655b1252ad194cda5ed7f6ddd6fc823127ae1dd (patch)
tree53e10a9a65585d23f1eee670ad1285847764c371 /src/pkg/strings/strings.go
parent046e2de9ba461c3b517b86e1e5962d40295264ab (diff)
downloadgolang-d655b1252ad194cda5ed7f6ddd6fc823127ae1dd.tar.gz
Basic HTTP client.
R=rsc APPROVED=rsc DELTA=392 (386 added, 2 deleted, 4 changed) OCL=29963 CL=30107
Diffstat (limited to 'src/pkg/strings/strings.go')
-rw-r--r--src/pkg/strings/strings.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go
index 2e3dc0215..035090777 100644
--- a/src/pkg/strings/strings.go
+++ b/src/pkg/strings/strings.go
@@ -53,6 +53,21 @@ func Index(s, sep string) int {
return -1
}
+// Index returns the index of the last instance of sep in s, or -1 if sep is not present in s.
+func LastIndex(s, sep string) int {
+ n := len(sep);
+ if n == 0 {
+ return len(s)
+ }
+ c := sep[0];
+ for i := len(s)-n; i >= 0; i-- {
+ if s[i] == c && (n == 1 || s[i:i+n] == sep) {
+ return i
+ }
+ }
+ return -1
+}
+
// Split returns the array representing the substrings of s separated by string sep. Adjacent
// occurrences of sep produce empty substrings. If sep is empty, it is the same as Explode.
func Split(s, sep string) []string {