# README
strings - text and string-type utilities
strings is a package for manipulating strings of text.
Installation
> go get github.com/go-corelibs/strings@latest
Examples
PathToSnake
func main() {
snakePath := PathToSnake("/this/path")
// snakePath == "this__path"
}
Go-CoreLibs
Go-CoreLibs is a repository of shared code between the Go-Curses and Go-Enjin projects.
License
Copyright 2023 The Go-CoreLibs Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Functions
AddLastSpace will add a space to value if value is non-empty and the last rune in value is not unicode.IsSpace.
AppendWithSpace appends add to src with a space, ensuring that only one space is separating the two given strings.
BookendRunes returns the first and last runes of the string, with `ok` being true when there is more than one rune in the input string.
Carve finds the `start` and `end` markers in `src` and carves out the "before carve", "middle of start/end range" and "after carve" segments.
CollapseSpaces returns the input string with all consecutive space characters collapsed to just one space character (tabs are not considered spaces).
Empty returns true if the string has a length of zero or is all spaces.
EscapeHtmlAttribute trims any matching outer quotations (single or double), replaces all double-quotes with `"` and returns the result.
FirstName is a wrapper around fullname_parser.ParseFullName.
GetBasicMime removes the semicolon and any trailing bits from the given mime string.
GetFancyQuote returns the FancyQuote pair matching the given rune.
IsAnyQuote returns true if all `runes` given match IsQuote or IsFancyQuote.
IsFalse is a wrapper around values.IsTruthy with the state inverted
Deprecated: please use values.IsTruthy instead.
IsFancyQuote returns true if all `runes` given match IsFancyQuote.
IsLastSpace returns ok=true if the string has a length greater than zero and space=true if the last rune is unicode.IsSpace.
IsQuote returns true if all `runes` given are one of double-quote ("), single-quote (') or backtick (`).
IsQuoted returns true if the first and last characters in the input are the same and are one of the three main quote types: single ('), double (") and literal (`).
IsQuotedFancy finds the starting and ending runes, returning true if they match any of the following pairs of quotations:.
IsSpaceOrPunct returns true if the value given is either unicode.IsSpace or unicode.IsPunct.
IsTrue is a wrapper around values.IsTrue
Deprecated: please use values.IsTruthy instead.
LastName is a wrapper around fullname_parser.ParseFullName.
NameFromEmail returns a user's default name based on just their email address, intended to be used as an interesting placeholder on a text input field for the user to supply something better.
NewByteBuffer returns a new ByteBuffer instance.
ParseDomainName returns the given name split into is component parts, in reverse order.
PathToSnake trims any leading and trailing slashes and converts the string to a snake_cased__directory_separated format where the directory separator is two underscores.
PruneSet returns the source string without any of the given runes.
PruneSpaces returns the input string without any space characters as defined by unicode.IsSpace.
PruneTmplActions removes all go template action statements
Note that this does not remove the content between if, else and end statements.
QuoteJsonValue is intended to be used when marshalling json content and is applied to only the json values as strings.
Scan is a text scanner which looks for unquoted and unescaped `sep`.
ScanBothCarve is like ScanCarve except that ScanBothCarve uses Scan to find both the `start` and `end` separators.
ScanCarve is like Carve except that ScanCarve uses Scan instead of [strings.Cut] for finding the `end` separator.
ScanLine searches for newline characters, counting up to the desired line number and returns just the text for that line.
ScanQuote looks for the first single, double or backtick quoted text, returning the `before`, `quoted` and `after` strings if `found`.
SortedByLastName returns a natual-sorted list of the full names given.
SplitSortReversed is a wrapper around strings.Split and reverses the order of the results.
ToDeepKey converts go template variables like `.ThisThing.Variable` to a map key used in like `.this-thing.variable`.
ToDeepVar is the opposite of ToDeepKey, translating `.this-thing.variable` to `.ThisThing.Variable` format.
ToKebabs converts all the given strings to kebab-case.
ToLowers converts all the given strings to lower case.
ToSpaced is a wrapper around strcase.ToDelimited with a space delimiter.
ToSpacedCamel is a wrapper around ToSpaced and strcase.ToCamel for each word.
ToSpacedTitle is a wrapper around ToSpaced and ToTitleWords.
ToTitleWords title-cases all words in the given text.
TrimPrefixes trims the first path prefix matching value, used to prune known things from arbitrary path strings which may or may not be prefixed with any of the prefixes given.
TrimQuotes returns the string with the first and last characters trimmed from the string if the string IsQuoted and returns the unmodified input string otherwise.
TrimTmplVar returns the name with leading `$` and `.` characters removed.
UniqueFromSpaceSep splits the given value on spaces and only appends it to the original slice if not already present, returning the updated results.
# Variables
No description provided by the author
# Structs
ByteBuffer is a wrapper around bytes.Buffer which implements the io.Closer interface so that it can be used in io.WriteCloser contexts.
No description provided by the author
# Type aliases
SortByLength implements the sort.Interface, sorting the slice from longest to shortest and sorting equal length strings using natural.Less.