github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/substr.html.md (about) 1 --- 2 layout: "functions" 3 page_title: "substr - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-string-substr" 5 description: |- 6 The substr function extracts a substring from a given string by offset and 7 length. 8 --- 9 10 # `substr` Function 11 12 -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and 13 earlier, see 14 [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html). 15 16 `substr` extracts a substring from a given string by offset and length. 17 18 ```hcl 19 substr(string, offset, length) 20 ``` 21 22 ## Examples 23 24 ``` 25 > substr("hello world", 1, 4) 26 ello 27 ``` 28 29 The offset and length are both counted in _unicode characters_ rather than 30 bytes: 31 32 ``` 33 > substr("🤔🤷", 0, 1) 34 🤔 35 ```