From d655b1252ad194cda5ed7f6ddd6fc823127ae1dd Mon Sep 17 00:00:00 2001 From: Steve Newman Date: Tue, 9 Jun 2009 10:58:58 -0700 Subject: Basic HTTP client. R=rsc APPROVED=rsc DELTA=392 (386 added, 2 deleted, 4 changed) OCL=29963 CL=30107 --- src/pkg/strings/strings.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/pkg/strings/strings.go') 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 { -- cgit v1.2.3