GOLF(2gg)
π GOLF(2gg) β the replace-string page, bestie edition π
okay so this is replace-string from GOLF(2gg), and it's literally the glow-up your strings have been waiting for. it lives in Development, it's part of the Strings fam, and it's about to make your text do a whole costume change. π¦β¨
β¨ NAME β¨
replace-string β (strings) π
π― PURPOSE π―
Replaces part of string. that's it. that's the whole job. iconic behaviour honestly. π
π SYNTAX π
replace-string <string> \
( copy <replacement> ) | ( copy-end <replacement> ) \
[ start-with <start with> ] \
[ length <length> ]
note the | in there β you pick one of copy or copy-end, not both. no double-dipping, bestie. π«Ά
πΈ DESCRIPTION πΈ
so here's the tea. replace-string will replace part of <string> with the <replacement> string. fr fr.
the "copy" clause makes a replacement in the leading part of <string>, while "copy-end" makes a replacement in the trailing part of <string>. front vibes vs. back vibes. π
if the "length" clause is not used, then the entire <replacement> string gets used. but if you do use it, only the <length> leading bytes of it come through. so length is basically the "only show up with this much" clause. π
if the "start-with" clause is used, then <replacement> will be copied starting with byte <start with> in <string> β and yes, "0" is the first byte, zero-indexed girlies rise up β¨ β that's with the "copy" clause. with the "copy-end" clause, it starts <start with> bytes prior to the end of <string> instead. same energy, opposite direction. π
if the "start-with" clause is not used, then <replacement> will replace the leading part of <string> (with the "copy" clause) or the very last part of <string> (with the "copy-end" clause). in either case, the number of bytes copied is determined by whether the "length" clause is used or not. so like, length is the ruler and start-with is the starting point, and if nobody says anything, things just default to the edges. π
π¨ important detail, don't skip this one: if either"start-with"or"length"is negative, it's the same as if not specified. so a negative number is basically a "no thoughts, head empty, ignore me" situation. π
π EXAMPLES π
example one β after replace-string below, string "a" will be "none string is here":
set-string b="none"
set-string a="some string is here"
replace-string a copy b
she said "i'm taking over the front of this string" and she did. ate and left no crumbs. π₯
example two β after replace-string below, string "a" will be "some string is none":
set-string b="none"
set-string a="some string is here"
replace-string a copy-end b
same idea but from the back this time. copy-end girlies, this one's for you. π
example three β in this example, "a" will be "somnontring is here":
set-string b="none"
set-string a="some string is here"
replace-string a copy b start-with 3 length 3
okay this one is a little surgical moment. start-with 3 and length 3 β precise, delicate, main character energy. π
example four β in the following example, "a" will be "some string inohere":
set-string b="none"
set-string a="some string is here"
replace-string a copy-end b start-with 6 length 2
copy-end with a start-with 6 and length 2? that's a targeted edit, bestie. chef's kiss. πβ¨
π SEE ALSO π
Strings
concatenate-strings copy-string count-substring delete-string lower-string new-string read-split replace-string set-string split-string string-length trim-string upper-string write-string See all documentation
π that's the whole page, no notes. go forth and replace some strings, you absolute icon. π
this was $VERSION, dated $DATE, and it's the GOLF(2gg) manual β so like, tag yourself in the group chat when you ship it. byeeee ππ¦β¨
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms