Carvel Logo

Strings

name1: #@ name + "-deployment"
name2: #@ "{}-deployment".format("name")

Copied here for convenience from Starlark specification.

"hello, world!".capitalize()  # "Hello, world!"`
"hello, world!".count("o")         # 2
"hello, world!".count("o", 7, 12)  # 1  (in "world")
"filename.star".endswith(".star")  # True
'foo.cc'.endswith(('.cc', '.h'))   # True
"bonbon".find("on")        # 1
"bonbon".find("on", 2)     # 4
"bonbon".find("on", 2, 5)  # -1
"a{x}b{y}c{}".format(1, x=2, y=3)   # "a2b3c1"
"a{}b{}c".format(1, 2)              # "a1b2c"
"({1}, {0})".format("zero", "one")  # "(one, zero)"
"bonbon".index("on")        # 1
"bonbon".index("on", 2)     # 4
"bonbon".index("on", 2, 5)  # error: substring not found (in "nbo")
"base64".isalnum()    # True
"Catch-22".isalnum()  # False
", ".join(["one", "two", "three"])  # "one, two, three"
"a".join("ctmrn".codepoints())      # "catamaran"
"  hello  ".lstrip()  # "hello  "
"banana".replace("a", "o")     # "bonono"
"banana".replace("a", "o", 2)  # "bonona"
"bonbon".rfind("on")           # 4
"bonbon".rfind("on", None, 5)  # 1
"bonbon".rfind("on", 2, 5)     # -1
"  hello  ".rstrip()  # "  hello"
"one two  three".split()         # ["one", "two", "three"]
"one two  three".split(" ")      # ["one", "two", "", "three"]
"one two  three".split(None, 1)  # ["one", "two  three"]
"banana".split("n")              # ["ba", "a", "a"]
"banana".split("n", 1)           # ["ba", "ana"]
"one\n\ntwo".splitlines()      # ["one", "", "two"]
"one\n\ntwo".splitlines(True)  # ["one\n", "\n", "two"]
"filename.star".startswith("filename")  # True`
"  hello  ".strip()  # "hello"
"Hello, World!".upper()  # "HELLO, WORLD!"

(Help improve our docs: edit this page on GitHub)