A Go string manipulation library. By Rajkumar Palani
A Go library for working with Strings. You can learn about all the String utility functions implemented in strman library by reading the documentation.
go get github.com/rajkumarpal07/strman
import (
"github.com/rajkumarpal07/strman"
)
- Appends - Appends strings to another string.
- AppendsArray - Appends an array of String to a string.
- At - Get the character at index.
- Base64Decode - Decodes data encoded with MIME base64.
- Base64Encode - Encodes data with MIME base64.
- Between - Returns an array with strings between start and end.
- Capitalize - Converts the first character of string to upper case and the remaining to lower case.
- Chars - Returns a String array consisting of the characters in the String.
- CharsCount - Counts the number of occurrences of each character in the string.
- CollapseWhitespace - Replace consecutive whitespace characters with a single space.
- Contains - Verifies that the needle is contained in the value. Case sensitive.
- ContainsAll - Verifies that all needles are contained in value. Case insensitive.
- ContainsAllCaseSensitive - Verifies that all needles are contained in value. Case sensitive.
- ContainsAny - Verifies that one or more of needles are contained in value. Case insensitive.
- ContainsAnyCaseSensitive - Verifies that one or more of needles are contained in value.
- CountSubstr - Count the number of times substr appears in value. Case Sensitive.
- CountSubstring - Count the number of times substr appears in value.
- CountsSubstr - Counts the number of times substr appears in value. Allows overlapping.
- Dasherize - Converts a underscored or camelized string into an dasherized one.
- DecEncode - Convert string chars to decimal unicode (16 digits).
- EndsWith - Tests if value ends with search.
- EndsWithCase - Tests if value ends with search. Case sensitive.
- EnsureLeft - Ensures that the value begins with prefix. If it doesn't exist, it's prepended. Case sensitive.
- EnsureLeftWithCase - Ensures that the value begins with prefix. If it doesn't exist, it's prepended.
- EnsureRight - Ensures that the value ends with suffix. If it doesn't, it's appended. Case sensitive.
- EnsureRightWithCase - Ensures that the value ends with suffix. If it doesn't, it's appended. Case sensitive.
- First - Returns the first 3 chars of String(ASCII).
- FirstNChars - Returns the first n chars of String(ASCII).
- Format - Formats a string using parameters. Will be added in a future release.
- FormatNumber - Returns a string where groups of three digits are delimited by comma.
- HTMLDecode - Converts all HTML entities to applicable characters.
- HTMLEncode - Convert all applicable characters to HTML entities.
- Head - Return the first char of String(ASCII).
- HexDecode - Convert hexadecimal unicode (4 digits) string to string chars.
- HexEncode - Convert string chars to hexadecimal unicode (4 digits).
- Humanize - Converts an underscored, camelized, or dasherized string into a humanized one.
- IndexOf - Returns the index within the calling String of the first occurrence of the specified value.
- Insert - Inserts 'substring' into the 'value' at the 'index' provided.
- IsBlank - Checks if string is empty.
- IsEnclosedBetween - Verifies whether String is enclosed by same encloser.
- IsEnclosedBetweenTwo - Verifies whether String is enclosed by 2 different enclosers.
- IsLowerCase - Verifies if String is lowercase.
- IsString - Checks whether parameter is String.
- IsUpperCase - Verifies if String is uppercase.
- Join - concatenates all the elements of the strings array into a single String.
- Last - Returns the last n chars of String.
- LastIndexOf - returns the index within the calling String object of the last occurrence of the specified value.
- LastIndexOfWithCase - returns the index of the last occurrence of the specified value. Case sensitive.
- LeftPad - Returns a new string such that the beginning of the string is padded.
- LeftPad2Len - Returns a new string of a given length such that the beginning of the string is padded.
- LeftTrim - Removes all spaces on left.
- Length - Returns length of String. Delegates to len method.
- Lines - Split lines to an array.
- LowerFirst - Converts the first character of string to lower case.
- Prepend - Returns a new String starting with 'prepends' string.
- PrependArray - Returns a new String starting with 'prepends' string array.
- RemoveEmptyStrings - Remove empty Strings from string array.
- RemoveLeft - Returns a new String with the prefix removed, if present. Case sensitive.
- RemoveLeftWithCase - Returns a new String with the prefix removed, if present.
- RemoveNonWords - Remove all non word characters.
- RemoveRight - Returns a new string with the 'suffix' removed, if present. Case sensitive.
- RemoveRightWithCase - Returns a new string with the 'suffix' removed, if present.
- RemoveSpaces - Removes all spaces.
- Repeat - Returns a repeated string given a multiplier.
- Replace - Replace all occurrences of 'search' value to 'newvalue'.
- Reverse - Reverse the input String.
- RightPad - Returns a new string such that the ending of the string is padded.
- RightPad2Len - Returns a new string of a given length such that the ending of the string is padded.
- RightTrim - Removes all spaces on right.
- SafeTruncate - Truncate the string securely, not cutting a word in half.
- Shuffle - Returns a string with its characters in random order.
- Slice - A substring method.
- Slugify - Convert a String to a slug.
- Split - Alias to String split function.
- Surround - Surrounds a 'value' with the given 'prefix' and 'suffix'.
- SwapCase - Returns a copy of the string in which all the case-based characters have had their case swapped.
- Tail - Returns tail of the String.
- ToCamelCase - Transform to camelCase.
- ToDecamelize - Decamelize String.
- ToKebabCase - Transform to kebab-case.
- ToSnakeCase - Transform to snake_case.
- ToStudlyCase - Transform to StudlyCaps.
- Transliterate - Remove all non valid characters.
- TrimEnd - Removes trailing chars from string.
- TrimEndSpaces - Removes trailing whitespace from string.
- TrimStart - Removes leading chars from string.
- TrimStartSpaces - Removes leading whitespace from string.
- Truncate - Truncates the unsecured form string, cutting the independent string of required position.
- UnEqual - Tests if two Strings are InEqual.
- Underscored - Changes passed in string to all lower case and adds underscore between words.
- UpperFirst - Converts the first character of string to upper case.
- Words - Splits a String to words.
- WordsDelimitedBy - Splits a String to words with a delimiter.
- Zip - Aggregates the contents of 2 strings arrays into a single list of tuples.
This library is inspired by dleitee/strman and shekhargulati/strman.
strman is licensed under the MIT License - see the LICENSE
file for details.