Copy as Markdown View as Markdown (opens in new tab) View on GitHub (opens in new tab) View llms.txt (opens in new tab) Open in... ChatGPT (opens in new tab) Claude (opens in new tab) Perplexity (opens in new tab) to to(from: Number, to: Number): Range Returns a range with the specified boundaries. The upper boundary is inclusive. Parameters Name Description from Number value that starts the range. The output includes the from value. to Number value that ends the range. The output includes the from value. Example This example lists a range of numbers from 1 to 10. Source %dw 2.0 output application/json --- { "myRange": 1 to 10 } Output { "myRange": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] } Example DataWeave treats a string as an array of characters. This example applies to to a string. Source %dw 2.0 var myVar = "Hello World!" output application/json --- { indices2to6 : myVar[2 to 6], indicesFromEnd : myVar[6 to -1], reversal : myVar[11 to -0] } Output { "indices2to6": "llo W", "indicesFromEnd": "World!", "reversal": "!dlroW olleH" }