RSplit, RFind in standard library

623 views
Skip to first unread message

nihil

unread,
Sep 10, 2016, 4:53:08 AM9/10/16
to golang-dev
Do you consider to add RSplit, RFind (like Python has) and other similar functions to standard library?

Brad Fitzpatrick

unread,
Sep 10, 2016, 11:45:27 AM9/10/16
to nihil, golang-dev
See https://golang.org/pkg/strings/

They're not named RWhatever, though. I think that's a feature.


On Sat, Sep 10, 2016 at 1:53 AM, nihil <6po...@gmail.com> wrote:
Do you consider to add RSplit, RFind (like Python has) and other similar functions to standard library?

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nihil

unread,
Sep 10, 2016, 12:56:11 PM9/10/16
to golang-dev, 6po...@gmail.com
From Python docs about rsplit: Except for splitting from the right, rsplit() behaves like split()
I didn't find anything similar in strings.
 
On Saturday, September 10, 2016 at 6:45:27 PM UTC+3, Brad Fitzpatrick wrote:
See https://golang.org/pkg/strings/

They're not named RWhatever, though. I think that's a feature.

On Sat, Sep 10, 2016 at 1:53 AM, nihil <6po...@gmail.com> wrote:
Do you consider to add RSplit, RFind (like Python has) and other similar functions to standard library?

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.

Brad Fitzpatrick

unread,
Sep 10, 2016, 1:10:17 PM9/10/16
to nihil, golang-dev
Okay, maybe we don't have things "from the right". I don't think that's useful enough for the standard library.


To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.

Austin Clements

unread,
Sep 10, 2016, 4:33:55 PM9/10/16
to Brad Fitzpatrick, nihil, golang-dev
nihil, strings.LastIndex is the equivalent of Python's rfind. You're right that there's no equivalent of RSplit.

On Sat, Sep 10, 2016 at 1:10 PM, Brad Fitzpatrick <brad...@golang.org> wrote:
Okay, maybe we don't have things "from the right". I don't think that's useful enough for the standard library.

The strings package has suffix or from-the-right versions of almost every anchored operation other than SplitN. It seems almost inconsistent to *not* have a SplitLastN.

nihil

unread,
Sep 10, 2016, 5:00:39 PM9/10/16
to golang-dev, brad...@golang.org, 6po...@gmail.com
I personally find strings.RFind to be a better name than strings.LastIndex.
Reply all
Reply to author
Forward
0 new messages