xstrings: 一组实用的Go语言字符串函数
jopen
10年前
Go包xstrings是一组在其他语言中被广泛使用字符串函数,但不存在于Go标准字符串包的集合中。所有功能都经过充分测试和精心调整性能。
Packagexstringsfunctions
Keep this table sorted by Function in ascending order.
| Function | Friends | # |
|---|---|---|
| Center | str.centerin Python;String#centerin Ruby | #30 |
| Count | String#countin Ruby | #16 |
| Delete | String#deletein Ruby | #17 |
| ExpandTabs | str.expandtabsin Python | #27 |
| FirstRuneToLower | lcfirstin PHP or Perl | #15 |
| FirstRuneToUpper | String#capitalizein Ruby;ucfirstin PHP or Perl | #15 |
| Insert | String#insertin Ruby | #18 |
| LastPartition | str.rpartitionin Python;String#rpartitionin Ruby | #19 |
| LeftJustify | str.ljustin Python;String#ljustin Ruby | #28 |
| Len | mb_strlenin PHP | #23 |
| Partition | str.partitionin Python;String#partitionin Ruby | #10 |
| Reverse | String#reversein Ruby;strrevin PHP;reversein Perl | #7 |
| RightJustify | str.rjustin Python;String#rjustin Ruby | #29 |
| RuneWidth | - | #27 |
| Scrub | String#scrubin Ruby | #20 |
| Shuffle | str_shufflein PHP | #13 |
| ShuffleSource | str_shufflein PHP | #13 |
| Slice | mb_substrin PHP | #9 |
| Squeeze | String#squeezein Ruby | #11 |
| Successor | String#succorString#nextin Ruby | #22 |
| SwapCase | str.swapcasein Python;String#swapcasein Ruby | #12 |
| ToCamelCase | String#camelizein RoR | #1 |
| ToSnakeCase | String#underscorein RoR | #1 |
| Translate | str.translatein Python;String#trin Ruby;strtrin PHP;tr///in Perl | #21 |
| Width | mb_strwidthin PHP | #26 |
| WordCount | str_word_countin PHP | #14 |
| WordSplit | - | #14 |
Packagestringsfunctions
Keep this table sorted by Function in ascending order.
| Function | Friends |
|---|---|
| Contains | String#include?in Ruby |
| ContainsAny | - |
| ContainsRune | - |
| Count | str.countin Python;substr_countin PHP |
| EqualFold | stricmpin PHP;String#casecmpin Ruby |
| Fields | str.splitin Python;splitin Perl;String#splitin Ruby |
| FieldsFunc | - |
| HasPrefix | str.startswithin Python;String#start_with?in Ruby |
| HasSuffix | str.endswithin Python;String#end_with?in Ruby |
| Index | str.indexin Python;String#indexin Ruby;strposin PHP;indexin Perl |
| IndexAny | - |
| IndexByte | - |
| IndexFunc | - |
| IndexRune | - |
| Join | str.joinin Python;Array#joinin Ruby;implodein PHP;joinin Perl |
| LastIndex | str.rindexin Python;String#rindex;strrposin PHP;rindexin Perl |
| LastIndexAny | - |
| LastIndexFunc | - |
| Map | String#each_codepointin Ruby |
| Repeat | operator*in Python and Ruby;str_repeatin PHP |
| Replace | str.replacein Python;String#subin Ruby;str_replacein PHP |
| Split | str.splitin Python;String#splitin Ruby;explodein PHP;splitin Perl |
| SplitAfter | - |
| SplitAfterN | - |
| SplitN | str.splitin Python;String#splitin Ruby;explodein PHP;splitin Perl |
| Title | str.titlein Python |
| ToLower | str.lowerin Python;String#downcasein Ruby;strtolowerin PHP;lcin Perl |
| ToLowerSpecial | - |
| ToTitle | - |
| ToTitleSpecial | - |
| ToUpper | str.upperin Python;String#upcasein Ruby;strtoupperin PHP;ucin Perl |
| ToUpperSpecial | - |
| Trim | str.stripin Python;String#stripin Ruby;trimin PHP |
| TrimFunc | - |
| TrimLeft | str.lstripin Python;String#lstripin Ruby;ltrimin PHP |
| TrimLeftFunc | - |
| TrimPrefix | - |
| TrimRight | str.rstripin Python;String#rstripin Ruby;rtrimin PHP |
| TrimRightFunc | - |
| TrimSpace | str.stripin Python;String#stripin Ruby;trimin PHP |
| TrimSuffix | String#chompin Ruby;chompin Perl |