<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>String functions on Hugo</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/</link><description>Recent content in String functions on Hugo</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://v0-122-0--gohugoio.netlify.app/functions/strings/index.xml" rel="self" type="application/rss+xml"/><item><title>strings.Chomp</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/chomp/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/chomp/</guid><description>If the argument is of type template.HTML, returns template.HTML, else returns a string.
{{ chomp | &amp;#34;foo\n&amp;#34; }} → foo {{ chomp | &amp;#34;foo\n\n&amp;#34; }} → foo {{ chomp | &amp;#34;foo\r\n&amp;#34; }} → foo {{ chomp | &amp;#34;foo\r\n\r\n&amp;#34; }} → foo</description></item><item><title>strings.Contains</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/contains/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/contains/</guid><description>{{ strings.Contains &amp;#34;Hugo&amp;#34; &amp;#34;go&amp;#34; }} → true The check is case sensitive:
{{ strings.Contains &amp;#34;Hugo&amp;#34; &amp;#34;Go&amp;#34; }} → false</description></item><item><title>strings.ContainsAny</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/containsany/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/containsany/</guid><description>{{ strings.ContainsAny &amp;#34;Hugo&amp;#34; &amp;#34;gm&amp;#34; }} → true The check is case sensitive:
{{ strings.ContainsAny &amp;#34;Hugo&amp;#34; &amp;#34;Gm&amp;#34; }} → false</description></item><item><title>strings.ContainsNonSpace</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/containsnonspace/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/containsnonspace/</guid><description>New in v0.111.0 {{ strings.ContainsNonSpace &amp;#34;\n&amp;#34; }} → false {{ strings.ContainsNonSpace &amp;#34; &amp;#34; }} → false {{ strings.ContainsNonSpace &amp;#34;\n abc&amp;#34; }} → true Common white space characters include:
&amp;#39;\t&amp;#39;, &amp;#39;\n&amp;#39;, &amp;#39;\v&amp;#39;, &amp;#39;\f&amp;#39;, &amp;#39;\r&amp;#39;, &amp;#39; &amp;#39; See the Unicode Character Database for a complete list.</description></item><item><title>strings.Count</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/count/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/count/</guid><description>If SUBSTR is an empty string, this function returns 1 plus the number of Unicode code points in STRING.
{{ &amp;#34;aaabaab&amp;#34; | strings.Count &amp;#34;a&amp;#34; }} → 5 {{ &amp;#34;aaabaab&amp;#34; | strings.Count &amp;#34;aa&amp;#34; }} → 2 {{ &amp;#34;aaabaab&amp;#34; | strings.Count &amp;#34;aaa&amp;#34; }} → 1 {{ &amp;#34;aaabaab&amp;#34; | strings.Count &amp;#34;&amp;#34; }} → 8</description></item><item><title>strings.CountRunes</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/countrunes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/countrunes/</guid><description>In contrast with the strings.RuneCount function, which counts every rune in a string, strings.CountRunes excludes whitespace.
{{ &amp;#34;Hello, 世界&amp;#34; | strings.CountRunes }} → 8</description></item><item><title>strings.CountWords</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/countwords/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/countwords/</guid><description>{{ &amp;#34;Hugo is a static site generator.&amp;#34; | countwords }} → 6</description></item><item><title>strings.FindRE</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/findre/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/findre/</guid><description>By default, findRE finds all matches. You can limit the number of matches with an optional LIMIT argument.
When specifying the regular expression, use a raw string literal (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
Go&amp;rsquo;s regular expression package implements the RE2 syntax. The RE2 syntax is a subset of that accepted by PCRE, roughly speaking, and with various caveats.</description></item><item><title>strings.FindRESubmatch</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/findresubmatch/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/findresubmatch/</guid><description>By default, findRESubmatch finds all matches. You can limit the number of matches with an optional LIMIT argument. A return value of nil indicates no match.
When specifying the regular expression, use a raw string literal (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
Go&amp;rsquo;s regular expression package implements the RE2 syntax. The RE2 syntax is a subset of that accepted by PCRE, roughly speaking, and with various caveats.</description></item><item><title>strings.FirstUpper</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/firstupper/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/firstupper/</guid><description>{{ strings.FirstUpper &amp;#34;foo&amp;#34; }} → Foo</description></item><item><title>strings.HasPrefix</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/hasprefix/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/hasprefix/</guid><description>{{ hasPrefix &amp;#34;Hugo&amp;#34; &amp;#34;Hu&amp;#34; }} → true</description></item><item><title>strings.HasSuffix</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/hassuffix/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/hassuffix/</guid><description>{{ hasSuffix &amp;#34;Hugo&amp;#34; &amp;#34;go&amp;#34; }} → true</description></item><item><title>strings.Repeat</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/repeat/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/repeat/</guid><description>{{ strings.Repeat 3 &amp;#34;yo&amp;#34; }} → yoyoyo</description></item><item><title>strings.Replace</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/replace/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/replace/</guid><description>{{ $s := &amp;#34;Batman and Robin&amp;#34; }} {{ replace $s &amp;#34;Robin&amp;#34; &amp;#34;Catwoman&amp;#34; }} → Batman and Catwoman Limit the number of replacements using the LIMIT argument:
{{ replace &amp;#34;aabbaabb&amp;#34; &amp;#34;a&amp;#34; &amp;#34;z&amp;#34; 2 }} → zzbbaabb</description></item><item><title>strings.ReplaceRE</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/replacere/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/replacere/</guid><description>When specifying the regular expression, use a raw string literal (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes.
Go&amp;rsquo;s regular expression package implements the RE2 syntax. The RE2 syntax is a subset of that accepted by PCRE, roughly speaking, and with various caveats. Note that the RE2 \C escape sequence is not supported.
{{ $s := &amp;#34;a-b--c---d&amp;#34; }} {{ replaceRE `(-{2,})` &amp;#34;-&amp;#34; $s }} → a-b-c-d Limit the number of replacements using the LIMIT argument:</description></item><item><title>strings.RuneCount</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/runecount/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/runecount/</guid><description>In contrast with the strings.CountRunes function, which excludes whitespace, strings.RuneCount counts every rune in a string.
{{ &amp;#34;Hello, 世界&amp;#34; | strings.RuneCount }} → 9</description></item><item><title>strings.SliceString</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/slicestring/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/slicestring/</guid><description>For example, 1 and 4 creates a slice including elements 1 through 3. The end index can be omitted; it defaults to the string&amp;rsquo;s length.
{{ slicestr &amp;#34;BatMan&amp;#34; 3 }}` → Man {{ slicestr &amp;#34;BatMan&amp;#34; 0 3 }}` → Bat</description></item><item><title>strings.Split</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/split/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/split/</guid><description>Examples:
{{ split &amp;#34;tag1,tag2,tag3&amp;#34; &amp;#34;,&amp;#34; }} → [&amp;#34;tag1&amp;#34;, &amp;#34;tag2&amp;#34;, &amp;#34;tag3&amp;#34;] {{ split &amp;#34;abc&amp;#34; &amp;#34;&amp;#34; }} → [&amp;#34;a&amp;#34;, &amp;#34;b&amp;#34;, &amp;#34;c&amp;#34;] The strings.Split function essentially does the opposite of the collections.Delimit function. While split creates a slice from a string, delimit creates a string from a slice.</description></item><item><title>strings.Substr</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/substr/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/substr/</guid><description>It normally takes two argument: start and length. It can also take one argument: start, i.e. length is omitted, in which case the substring starting from start until the end of the string will be returned.
To extract characters from the end of the string, use a negative start number.
If length is given and is negative, that number of characters will be omitted from the end of string.
{{ substr &amp;#34;abcdef&amp;#34; 0 }} → abcdef {{ substr &amp;#34;abcdef&amp;#34; 1 }} → bcdef {{ substr &amp;#34;abcdef&amp;#34; 0 1 }} → a {{ substr &amp;#34;abcdef&amp;#34; 1 1 }} → b {{ substr &amp;#34;abcdef&amp;#34; 0 -1 }} → abcde {{ substr &amp;#34;abcdef&amp;#34; 1 -1 }} → bcde {{ substr &amp;#34;abcdef&amp;#34; -1 }} → f {{ substr &amp;#34;abcdef&amp;#34; -2 }} → ef {{ substr &amp;#34;abcdef&amp;#34; -1 1 }} → f {{ substr &amp;#34;abcdef&amp;#34; -2 1 }} → e {{ substr &amp;#34;abcdef&amp;#34; -3 -1 }} → de {{ substr &amp;#34;abcdef&amp;#34; -3 -2 }} → d</description></item><item><title>strings.Title</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/title/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/title/</guid><description>{{ title &amp;#34;table of contents (TOC)&amp;#34; }} → Table of Contents (TOC) By default, Hugo follows the capitalization rules published in the Associated Press Stylebook. Change your site configuration if you would prefer to:
Follow the capitalization rules published in the Chicago Manual of Style Capitalize the first letter of every word Capitalize the first letter of the first word Disable the effects of the title function The last option is useful if your theme uses the title function, and you would prefer to manually capitalize strings as needed.</description></item><item><title>strings.ToLower</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/tolower/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/tolower/</guid><description>{{ lower &amp;#34;BatMan&amp;#34; }} → batman</description></item><item><title>strings.ToUpper</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/toupper/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/toupper/</guid><description>{{ upper &amp;#34;BatMan&amp;#34; }} → BATMAN</description></item><item><title>strings.Trim</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/trim/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/trim/</guid><description>{{ trim &amp;#34;++foo--&amp;#34; &amp;#34;+-&amp;#34; }} → foo To remove leading and trailing newline characters and carriage returns:
{{ trim &amp;#34;\nfoo\n&amp;#34; &amp;#34;\n\r&amp;#34; }} → foo {{ trim &amp;#34;\n\nfoo\n\n&amp;#34; &amp;#34;\n\r&amp;#34; }} → foo {{ trim &amp;#34;\r\nfoo\r\n&amp;#34; &amp;#34;\n\r&amp;#34; }} → foo {{ trim &amp;#34;\r\n\r\nfoo\r\n\r\n&amp;#34; &amp;#34;\n\r&amp;#34; }} → foo The strings.Trim function is commonly used in shortcodes to remove leading and trailing newlines characters and carriage returns from the content within the opening and closing shortcode tags.</description></item><item><title>strings.TrimLeft</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimleft/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimleft/</guid><description>{{ strings.TrimLeft &amp;#34;a&amp;#34; &amp;#34;abba&amp;#34; }} → bba The strings.TrimLeft function converts the arguments to strings if possible:
{{ strings.TrimLeft 21 12345 }} → 345 (string) {{ strings.TrimLeft &amp;#34;rt&amp;#34; true }} → ue</description></item><item><title>strings.TrimPrefix</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimprefix/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimprefix/</guid><description>{{ strings.TrimPrefix &amp;#34;a&amp;#34; &amp;#34;aabbaa&amp;#34; }} → abbaa {{ strings.TrimPrefix &amp;#34;aa&amp;#34; &amp;#34;aabbaa&amp;#34; }} → bbaa {{ strings.TrimPrefix &amp;#34;aaa&amp;#34; &amp;#34;aabbaa&amp;#34; }} → aabbaa</description></item><item><title>strings.TrimRight</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimright/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimright/</guid><description>{{ strings.TrimRight &amp;#34;a&amp;#34; &amp;#34;abba&amp;#34; }} → abb The strings.TrimRight function converts the arguments to strings if possible:
{{ strings.TrimRight 54 12345 }} → 123 (string) {{ strings.TrimRight &amp;#34;eu&amp;#34; true }} → tr</description></item><item><title>strings.TrimSuffix</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimsuffix/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/trimsuffix/</guid><description>{{ strings.TrimSuffix &amp;#34;a&amp;#34; &amp;#34;aabbaa&amp;#34; }} → aabba {{ strings.TrimSuffix &amp;#34;aa&amp;#34; &amp;#34;aabbaa&amp;#34; }} → aabb {{ strings.TrimSuffix &amp;#34;aaa&amp;#34; &amp;#34;aabbaa&amp;#34; }} → aabbaa</description></item><item><title>strings.Truncate</title><link>https://v0-122-0--gohugoio.netlify.app/functions/strings/truncate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/strings/truncate/</guid><description>Since Go templates are HTML-aware, truncate will intelligently handle normal strings vs HTML strings:
{{ &amp;#34;&amp;lt;em&amp;gt;Keep my HTML&amp;lt;/em&amp;gt;&amp;#34; | safeHTML | truncate 10 }} → &amp;lt;em&amp;gt;Keep my …&amp;lt;/em&amp;gt; If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the safeHTMLfunction before sending the value to truncate. Otherwise, the HTML tags will be escaped when passed through the truncate function.</description></item></channel></rss>