HUGO
News Docs Themes Community GitHub

strings.Chomp

strings.Chomp STRING

Returns the given string, removing all trailing newline characters and carriage returns.

strings.Contains

strings.Contains STRING SUBSTRING

Reports whether the given string contains the given substring.

strings.ContainsAny

strings.ContainsAny STRING SET

Reports whether the given string contains any character within the given set.

strings.ContainsNonSpace

strings.ContainsNonSpace STRING

Reports whether the given string contains any non-space characters as defined by Unicode.

strings.Count

strings.Count SUBSTR STRING

Returns the number of non-overlapping instances of the given substring within the given string.

strings.CountRunes

strings.CountRunes INPUT

Returns the number of runes in the given string excluding whitespace.

strings.CountWords

strings.CountWords INPUT

Returns the number of words in the given string.

strings.Diff

strings.Diff OLDNAME OLD NEWNAME NEW

Returns an anchored diff of the two texts OLD and NEW in the unified diff format. If OLD and NEW are identical, returns an empty string.

strings.FindRE

strings.FindRE PATTERN INPUT [LIMIT]

Returns a slice of strings that match the regular expression.

strings.FindRESubmatch

strings.FindRESubmatch PATTERN INPUT [LIMIT]

Returns a slice of all successive matches of the regular expression. Each element is a slice of strings holding the text of the leftmost match of the regular expression and the matches, if any, of its subexpressions.

strings.FirstUpper

strings.FirstUpper STRING

Returns the given string, capitalizing the first character.

strings.HasPrefix

strings.HasPrefix STRING PREFIX

Reports whether the given string begins with the given prefix.

strings.HasSuffix

strings.HasSuffix STRING SUFFIX

Reports whether the given string ends with the given suffix.

strings.Repeat

strings.Repeat COUNT INPUT

Returns a new string consisting of zero or more copies of another string.

strings.Replace

strings.Replace INPUT OLD NEW [LIMIT]

Returns a copy of INPUT, replacing all occurrences of OLD with NEW.

strings.ReplaceRE

strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]

Returns a copy of INPUT, replacing all occurrences of a regular expression with a replacement pattern.

strings.RuneCount

strings.RuneCount INPUT

Returns the number of runes in the given string.

strings.SliceString

strings.SliceString STRING [START] [END]

Returns a substring of the given string, beginning with the start position and ending before the end position.

strings.Split

strings.Split STRING DELIM

Returns a slice of strings by splitting the given string by a delimiter.

strings.Substr

strings.Substr STRING [START] [LENGTH]

Returns a substring of the given string, beginning with the start position and ending after the given length.

strings.Title

strings.Title STRING

Returns the given string, converting it to title case.

strings.ToLower

strings.ToLower INPUT

Returns the given string, converting all characters to lowercase.

strings.ToUpper

strings.ToUpper INPUT

Returns the given string, converting all characters to uppercase.

strings.Trim

strings.Trim INPUT CUTSET

Returns the given string, removing leading and trailing characters specified in the cutset.

strings.TrimLeft

strings.TrimLeft CUTSET STRING

Returns the given string, removing leading characters specified in the cutset.

strings.TrimPrefix

strings.TrimPrefix PREFIX STRING

Returns the given string, removing the prefix from the beginning of the string.

strings.TrimRight

strings.TrimRight CUTSET STRING

Returns the given string, removing trailing characters specified in the cutset.

strings.TrimSpace

strings.TrimSpace INPUT

Returns the given string, removing leading and trailing whitespace as defined by Unicode.

strings.TrimSuffix

strings.TrimSuffix SUFFIX STRING

Returns the given string, removing the suffix from the end of the string.

strings.Truncate

strings.Truncate SIZE [ELLIPSIS] INPUT

Returns the given string, truncating it to a maximum length without cutting words or leaving unclosed HTML tags.