substring
FEEL built-in function · FEEL string functions
substring(string, start position, length?)
Returns the part of the string that starts at start position. Without length, it runs to the end of the string; a negative start position counts backwards from the end.
A negative start position counts from the end: -1 is the last character, -3 the third from last. DMN 1.6 defines substring only for positions inside the string: the start position must be non-zero and within [-length..length], and the length must be at least 1 and must not run past the end. Anything else is outside the function's domain, and the result is null. A fractional start position or length is truncated, as for every integer parameter of a built-in.
Parameters
| Parameter | Type | Description |
|---|---|---|
| string | string | the source string |
| start position | number | 1-based start; negative counts from the end |
| length | number | maximum characters to return (optional) |
Examples
substring("foobar", 3)
substring("foobar", 3, 3)
substring("foobar", -2, 1)
Edge cases and null handling
substring("foobar", 10)
A start position beyond the string is outside the domain. B-FEEL returns the empty string.
Part of FEEL string functions: the rules all of them share, string concatenation, regex pitfalls and every function side by side.
Related functions
substring before · substring after · string length
Defined by the OMG DMN 1.6 specification, chapter 10.3.4 (built-in functions).