String
This page describes the list of available functions for templates, related to strings:
SplitWords( value: string ): []string
→ Splits the given value in words and returns the corresponding slice, not that words are separated by spaces only and do not include punctuation!JoinText( separator: string, slice: []string ): string
→ Joins the given slice using separator as the join string, ie, the reverse of split words if you use space as separator;PascalCase( value: string ): string
→ Converts the given value to Pascal Case, while trimming the leading and trailing spaces;DromedaryCase( value: string ): string
→ Converts the given value to Dromedary Case, while trimming the leading and trailing spaces;SnailCase( value: string ): string
→ Converts the given value to Snail Case, while trimming the leading and trailing spaces;ConstantCase( value: string ): string
→ Converts the given value to Constant Case, while trimming the leading and trailing spaces;DashCase( value: string ): string
→ Converts the given value to Dash Case, while trimming the leading and trailing spaces;TrainCase( value: string ): string
→ Converts the given value to Train Case, while trimming the leading and trailing spaces;HTTPHeaderCase( value: string ): string
→ Converts the given value to Http Header Case, while trimming the leading and trailing spaces;StartCase( value: string ): string
→ Converts the given value to Start Case, while trimming the leading and trailing spaces;SentenceCase( value: string ): string
→ Converts the given value to Sentence Case, while trimming the leading and trailing spaces;UpperCase( value: string ): string
→ Converts the given value to Upper Case, while trimming the leading and trailing spaces;LowerCase( value: string ): string
→ Converts the given value to Lower Case, while trimming the leading and trailing spaces;StickyCase( value: string ): string
→ Converts the given value to Sticky Case, while trimming the leading and trailing spaces;EndsWith( value: string, suffix: string ): bool
→ Checks if the given value has the given suffix;StartsWith( value: string, prefix: string ): bool
→ Checks if the given value has the given prefix;Trim( value: string, chars: []rune ): string
→ Trims the runes in the chars slice, from the leading and trailing value string;TrimSpace( value: string ): string
→ Trims the leading and trailing spaces;TrimPrefix( value: string, prefix: string ): string
→ Trims the leading prefix from the value string;TrimSuffix( value: string, suffix: string ): string
→ Trims the trailing suffix from the value string;ContainsSubstring( value: string, regex: string ): bool
→ Checks if value matches the given regex;Cut(value: string, sep: string): []string
→ Cuts the string around the first instance of separator, returning the text before and after sep;CutPrefix(value: string, prefix: string): string
→ Returns value without the provided leading prefix string;CutSuffix(value: string, suffix: string): string
→ Returns value without the provided ending suffix string;Index(value: string, substr: string): int
→ Returns the index of the first instance of substr in value, or -1 if substr is not present in value;IndexRune(value: string, rune: rune): int
→ Returns the index of the first instance of the Unicode code point rune, or -1 if rune is not present in value;LastIndex(value: string, substr: string): int
→ Returns the index of the last instance of substr in value, or -1 if substr is not present in value;Repeat(value: string, count: uint): string
→ Returns a new string consisting of count copies of the string value;ReplaceAll(value: string, old: string, new: string): string
→ Returns a copy of the string value with all non-overlapping instances of old replaced by new;Count(value: string, substr: string): uint
→ Counts the number of non-overlapping instances of substr in value;ContainsRune(value: string, rune: rune): bool
→ Returns whether the Unicode code point rune is within value;
Aliases
The following functions are aliases:
- UpperCamelCase → Alias to PascalCase;
- LowerCamelCase → Alias to DromedaryCase;
- LowerSnakeCase → Alias to SnailCase;
- UpperSnakeCase → Alias to ConstantCase;
- LowerKebabCase → Alias to DashCase;
- UpperKebabCase → Alias to TrainCase;
- TitleKebabCase → Alias to HTTPHeaderCase.