• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D10-Jun-2020266

.travis.ymlH A D10-Jun-2020355

CONTRIBUTING.mdH A D10-Jun-20201.4 KiB

LICENSEH A D10-Jun-20201 KiB

README.mdH A D10-Jun-202010 KiB

common.goH A D10-Jun-2020520

convert.goH A D10-Jun-202011.5 KiB

convert_test.goH A D10-Jun-20205.3 KiB

count.goH A D10-Jun-20202.2 KiB

count_test.goH A D10-Jun-20201.2 KiB

doc.goH A D10-Jun-2020384

format.goH A D10-Jun-20204 KiB

format_test.goH A D10-Jun-20202.9 KiB

go.modH A D10-Jun-202043

manipulate.goH A D10-Jun-20204.3 KiB

manipulate_test.goH A D10-Jun-20204.7 KiB

stringbuilder.goH A D10-Jun-202090

stringbuilder_go110.goH A D10-Jun-202096

translate.goH A D10-Jun-202011.8 KiB

translate_test.goH A D10-Jun-20202.8 KiB

util_test.goH A D10-Jun-2020619

README.md

1# xstrings #
2
3[![Build Status](https://travis-ci.org/huandu/xstrings.svg?branch=master)](https://travis-ci.org/huandu/xstrings)
4[![GoDoc](https://godoc.org/github.com/huandu/xstrings?status.svg)](https://godoc.org/github.com/huandu/xstrings)
5[![Go Report](https://goreportcard.com/badge/github.com/huandu/xstrings)](https://goreportcard.com/report/github.com/huandu/xstrings)
6[![Coverage Status](https://coveralls.io/repos/github/huandu/xstrings/badge.svg?branch=master)](https://coveralls.io/github/huandu/xstrings?branch=master)
7
8Go package [xstrings](https://godoc.org/github.com/huandu/xstrings) is a collection of string functions, which are widely used in other languages but absent in Go package [strings](http://golang.org/pkg/strings).
9
10All functions are well tested and carefully tuned for performance.
11
12## Propose a new function ##
13
14Please review [contributing guideline](CONTRIBUTING.md) and [create new issue](https://github.com/huandu/xstrings/issues) to state why it should be included.
15
16## Install ##
17
18Use `go get` to install this library.
19
20    go get github.com/huandu/xstrings
21
22## API document ##
23
24See [GoDoc](https://godoc.org/github.com/huandu/xstrings) for full document.
25
26## Function list ##
27
28Go functions have a unique naming style. One, who has experience in other language but new in Go, may have difficulties to find out right string function to use.
29
30Here is a list of functions in [strings](http://golang.org/pkg/strings) and [xstrings](https://godoc.org/github.com/huandu/xstrings) with enough extra information about how to map these functions to their friends in other languages. Hope this list could be helpful for fresh gophers.
31
32### Package `xstrings` functions ###
33
34*Keep this table sorted by Function in ascending order.*
35
36| Function | Friends | # |
37| -------- | ------- | --- |
38| [Center](https://godoc.org/github.com/huandu/xstrings#Center) | `str.center` in Python; `String#center` in Ruby | [#30](https://github.com/huandu/xstrings/issues/30) |
39| [Count](https://godoc.org/github.com/huandu/xstrings#Count) | `String#count` in Ruby | [#16](https://github.com/huandu/xstrings/issues/16) |
40| [Delete](https://godoc.org/github.com/huandu/xstrings#Delete) | `String#delete` in Ruby | [#17](https://github.com/huandu/xstrings/issues/17) |
41| [ExpandTabs](https://godoc.org/github.com/huandu/xstrings#ExpandTabs) | `str.expandtabs` in Python | [#27](https://github.com/huandu/xstrings/issues/27) |
42| [FirstRuneToLower](https://godoc.org/github.com/huandu/xstrings#FirstRuneToLower) | `lcfirst` in PHP or Perl | [#15](https://github.com/huandu/xstrings/issues/15) |
43| [FirstRuneToUpper](https://godoc.org/github.com/huandu/xstrings#FirstRuneToUpper) | `String#capitalize` in Ruby; `ucfirst` in PHP or Perl | [#15](https://github.com/huandu/xstrings/issues/15) |
44| [Insert](https://godoc.org/github.com/huandu/xstrings#Insert) | `String#insert` in Ruby | [#18](https://github.com/huandu/xstrings/issues/18) |
45| [LastPartition](https://godoc.org/github.com/huandu/xstrings#LastPartition) | `str.rpartition` in Python; `String#rpartition` in Ruby | [#19](https://github.com/huandu/xstrings/issues/19) |
46| [LeftJustify](https://godoc.org/github.com/huandu/xstrings#LeftJustify) | `str.ljust` in Python; `String#ljust` in Ruby | [#28](https://github.com/huandu/xstrings/issues/28) |
47| [Len](https://godoc.org/github.com/huandu/xstrings#Len) | `mb_strlen` in PHP | [#23](https://github.com/huandu/xstrings/issues/23) |
48| [Partition](https://godoc.org/github.com/huandu/xstrings#Partition) | `str.partition` in Python; `String#partition` in Ruby | [#10](https://github.com/huandu/xstrings/issues/10) |
49| [Reverse](https://godoc.org/github.com/huandu/xstrings#Reverse) | `String#reverse` in Ruby; `strrev` in PHP; `reverse` in Perl | [#7](https://github.com/huandu/xstrings/issues/7) |
50| [RightJustify](https://godoc.org/github.com/huandu/xstrings#RightJustify) | `str.rjust` in Python; `String#rjust` in Ruby | [#29](https://github.com/huandu/xstrings/issues/29) |
51| [RuneWidth](https://godoc.org/github.com/huandu/xstrings#RuneWidth) | - | [#27](https://github.com/huandu/xstrings/issues/27) |
52| [Scrub](https://godoc.org/github.com/huandu/xstrings#Scrub) | `String#scrub` in Ruby | [#20](https://github.com/huandu/xstrings/issues/20) |
53| [Shuffle](https://godoc.org/github.com/huandu/xstrings#Shuffle) | `str_shuffle` in PHP | [#13](https://github.com/huandu/xstrings/issues/13) |
54| [ShuffleSource](https://godoc.org/github.com/huandu/xstrings#ShuffleSource) | `str_shuffle` in PHP | [#13](https://github.com/huandu/xstrings/issues/13) |
55| [Slice](https://godoc.org/github.com/huandu/xstrings#Slice) | `mb_substr` in PHP | [#9](https://github.com/huandu/xstrings/issues/9) |
56| [Squeeze](https://godoc.org/github.com/huandu/xstrings#Squeeze) | `String#squeeze` in Ruby | [#11](https://github.com/huandu/xstrings/issues/11) |
57| [Successor](https://godoc.org/github.com/huandu/xstrings#Successor) | `String#succ` or `String#next` in Ruby | [#22](https://github.com/huandu/xstrings/issues/22) |
58| [SwapCase](https://godoc.org/github.com/huandu/xstrings#SwapCase) | `str.swapcase` in Python; `String#swapcase` in Ruby | [#12](https://github.com/huandu/xstrings/issues/12) |
59| [ToCamelCase](https://godoc.org/github.com/huandu/xstrings#ToCamelCase) | `String#camelize` in RoR | [#1](https://github.com/huandu/xstrings/issues/1) |
60| [ToKebab](https://godoc.org/github.com/huandu/xstrings#ToKebabCase) | - | [#41](https://github.com/huandu/xstrings/issues/41) |
61| [ToSnakeCase](https://godoc.org/github.com/huandu/xstrings#ToSnakeCase) | `String#underscore` in RoR | [#1](https://github.com/huandu/xstrings/issues/1) |
62| [Translate](https://godoc.org/github.com/huandu/xstrings#Translate) | `str.translate` in Python; `String#tr` in Ruby; `strtr` in PHP; `tr///` in Perl | [#21](https://github.com/huandu/xstrings/issues/21) |
63| [Width](https://godoc.org/github.com/huandu/xstrings#Width) | `mb_strwidth` in PHP | [#26](https://github.com/huandu/xstrings/issues/26) |
64| [WordCount](https://godoc.org/github.com/huandu/xstrings#WordCount) | `str_word_count` in PHP | [#14](https://github.com/huandu/xstrings/issues/14) |
65| [WordSplit](https://godoc.org/github.com/huandu/xstrings#WordSplit) | - | [#14](https://github.com/huandu/xstrings/issues/14) |
66
67### Package `strings` functions ###
68
69*Keep this table sorted by Function in ascending order.*
70
71| Function | Friends |
72| -------- | ------- |
73| [Contains](http://golang.org/pkg/strings/#Contains) | `String#include?` in Ruby |
74| [ContainsAny](http://golang.org/pkg/strings/#ContainsAny) | - |
75| [ContainsRune](http://golang.org/pkg/strings/#ContainsRune) | - |
76| [Count](http://golang.org/pkg/strings/#Count) | `str.count` in Python; `substr_count` in PHP |
77| [EqualFold](http://golang.org/pkg/strings/#EqualFold) | `stricmp` in PHP; `String#casecmp` in Ruby |
78| [Fields](http://golang.org/pkg/strings/#Fields) | `str.split` in Python; `split` in Perl; `String#split` in Ruby |
79| [FieldsFunc](http://golang.org/pkg/strings/#FieldsFunc) | - |
80| [HasPrefix](http://golang.org/pkg/strings/#HasPrefix) | `str.startswith` in Python; `String#start_with?` in Ruby |
81| [HasSuffix](http://golang.org/pkg/strings/#HasSuffix) | `str.endswith` in Python; `String#end_with?` in Ruby |
82| [Index](http://golang.org/pkg/strings/#Index) | `str.index` in Python; `String#index` in Ruby; `strpos` in PHP; `index` in Perl |
83| [IndexAny](http://golang.org/pkg/strings/#IndexAny) | - |
84| [IndexByte](http://golang.org/pkg/strings/#IndexByte) | - |
85| [IndexFunc](http://golang.org/pkg/strings/#IndexFunc) | - |
86| [IndexRune](http://golang.org/pkg/strings/#IndexRune) | - |
87| [Join](http://golang.org/pkg/strings/#Join) | `str.join` in Python; `Array#join` in Ruby; `implode` in PHP; `join` in Perl |
88| [LastIndex](http://golang.org/pkg/strings/#LastIndex) | `str.rindex` in Python; `String#rindex`; `strrpos` in PHP; `rindex` in Perl |
89| [LastIndexAny](http://golang.org/pkg/strings/#LastIndexAny) | - |
90| [LastIndexFunc](http://golang.org/pkg/strings/#LastIndexFunc) | - |
91| [Map](http://golang.org/pkg/strings/#Map) | `String#each_codepoint` in Ruby |
92| [Repeat](http://golang.org/pkg/strings/#Repeat) | operator `*` in Python and Ruby; `str_repeat` in PHP |
93| [Replace](http://golang.org/pkg/strings/#Replace) | `str.replace` in Python; `String#sub` in Ruby; `str_replace` in PHP |
94| [Split](http://golang.org/pkg/strings/#Split) | `str.split` in Python; `String#split` in Ruby; `explode` in PHP; `split` in Perl |
95| [SplitAfter](http://golang.org/pkg/strings/#SplitAfter) | - |
96| [SplitAfterN](http://golang.org/pkg/strings/#SplitAfterN) | - |
97| [SplitN](http://golang.org/pkg/strings/#SplitN) | `str.split` in Python; `String#split` in Ruby; `explode` in PHP; `split` in Perl |
98| [Title](http://golang.org/pkg/strings/#Title) | `str.title` in Python |
99| [ToLower](http://golang.org/pkg/strings/#ToLower) | `str.lower` in Python; `String#downcase` in Ruby; `strtolower` in PHP; `lc` in Perl |
100| [ToLowerSpecial](http://golang.org/pkg/strings/#ToLowerSpecial) | - |
101| [ToTitle](http://golang.org/pkg/strings/#ToTitle) | - |
102| [ToTitleSpecial](http://golang.org/pkg/strings/#ToTitleSpecial) | - |
103| [ToUpper](http://golang.org/pkg/strings/#ToUpper) | `str.upper` in Python; `String#upcase` in Ruby; `strtoupper` in PHP; `uc` in Perl |
104| [ToUpperSpecial](http://golang.org/pkg/strings/#ToUpperSpecial) | - |
105| [Trim](http://golang.org/pkg/strings/#Trim) | `str.strip` in Python; `String#strip` in Ruby; `trim` in PHP |
106| [TrimFunc](http://golang.org/pkg/strings/#TrimFunc) | - |
107| [TrimLeft](http://golang.org/pkg/strings/#TrimLeft) | `str.lstrip` in Python; `String#lstrip` in Ruby; `ltrim` in PHP |
108| [TrimLeftFunc](http://golang.org/pkg/strings/#TrimLeftFunc) | - |
109| [TrimPrefix](http://golang.org/pkg/strings/#TrimPrefix) | - |
110| [TrimRight](http://golang.org/pkg/strings/#TrimRight) | `str.rstrip` in Python; `String#rstrip` in Ruby; `rtrim` in PHP |
111| [TrimRightFunc](http://golang.org/pkg/strings/#TrimRightFunc) | - |
112| [TrimSpace](http://golang.org/pkg/strings/#TrimSpace) | `str.strip` in Python; `String#strip` in Ruby; `trim` in PHP |
113| [TrimSuffix](http://golang.org/pkg/strings/#TrimSuffix) | `String#chomp` in Ruby; `chomp` in Perl |
114
115## License ##
116
117This library is licensed under MIT license. See LICENSE for details.
118