xstrings
Go package xstrings is a collection of string functions, which are widely used in other languages but absent in Go package strings.
All functions are well tested and carefully tuned for performance.
Propose a new function
Please review contributing guideline and create new issue to state why it should be included.
Install
Use go get to install this library.
go get github.com/huandu/xstringsAPI document
See GoDoc for full document.
Function list
Go 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.
Here is a list of functions in strings and 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.
Package xstrings functions
Keep this table sorted by Function in ascending order.
Package strings functions
Keep this table sorted by Function in ascending order.
String#include? in Ruby
str.count in Python; substr_count in PHP
stricmp in PHP; String#casecmp in Ruby
str.split in Python; split in Perl; String#split in Ruby
str.startswith in Python; String#start_with? in Ruby
str.endswith in Python; String#end_with? in Ruby
str.index in Python; String#index in Ruby; strpos in PHP; index in Perl
str.join in Python; Array#join in Ruby; implode in PHP; join in Perl
str.rindex in Python; String#rindex; strrpos in PHP; rindex in Perl
String#each_codepoint in Ruby
operator * in Python and Ruby; str_repeat in PHP
str.replace in Python; String#sub in Ruby; str_replace in PHP
str.split in Python; String#split in Ruby; explode in PHP; split in Perl
str.split in Python; String#split in Ruby; explode in PHP; split in Perl
str.title in Python
str.lower in Python; String#downcase in Ruby; strtolower in PHP; lc in Perl
str.upper in Python; String#upcase in Ruby; strtoupper in PHP; uc in Perl
str.strip in Python; String#strip in Ruby; trim in PHP
str.lstrip in Python; String#lstrip in Ruby; ltrim in PHP
str.rstrip in Python; String#rstrip in Ruby; rtrim in PHP
str.strip in Python; String#strip in Ruby; trim in PHP
String#chomp in Ruby; chomp in Perl
License
This library is licensed under MIT license. See LICENSE for details.
Last updated
Was this helpful?