Formulas for extracting data from strings

Use the following formulas to:

Formula patterns

TO USE
Extract the length of a string $StrLen(string)$
Extract the position of a specified string series (case-sensitive) $StrPos((where-to-search), what-to-search-for, idx)$
Extract the position of a specified string series (not case-sensitive) $StrPosNoCase((where-to-search), what-to-search-for, idx)$
Extract string series $SubStrIdx(where-to-search, first-idx[, last-idx])$
Extract a specified number of characters $SubStrLen((where-to-search, first-idx[, length])$

NOTES

* Zero-based counting is applied: the first item is counted as 0, the second as 1, and so on. The following rules apply:

Examples

The examples that follow refer to a material named W-12xy EB-WB-00.

NOTE: In the formulas, n0 ensures that the result will appear as an integer and that no zeroes will appear after the decimal point.

To print Use Example Because
The number of string items, spaces included $StrLen((#OneUp1.Material.Name)), n0$ 15  
The position of the first dash $StrPos((#OneUp1.Material.Name), "–", 0), n0$ 1  
The position of the second dash $StrPos((#OneUp1.Material.Name), "–", 1), n0$ 9  
The position of the third dash $StrPos((#OneUp1.Material.Name), "–", 2), n0$ 12  
The position of the fourth dash $StrPos((#OneUp1.Material.Name), "–", 3), n0$ –1 There is no fourth dash in the string.
The position of the first dash from right to left $StrPos((#OneUp1.Material.Name), "–", –1), n0$ 3 In right-to-left counting, the first position counts as 1.
The position of the letter "E" $StrPos((#OneUp1.Material.Name), "EB"), n0$ 7  
The the position of the letters "eb" $StrPos((#OneUp1.Material.Name), "eb"), n0$ -1 Because case-sensitivity is respected, the item series "eb" has not been found.
The position of the letter "E" $StrPosNoCase((#OneUp1.Material.Name), "EB"), n0$ 7 The position of the letter "E". No case-sensitivity.
The position of the letter "E" $StrPosNoCase((#OneUp1.Material.Name), "eb"), n0$ 7 The position of the letter "E". No case-sensitivity.
The symbols between two specified string positions $SubStrIdx((#OneUp1.Material.Name), strpos((#OneUp1.Material.Name), "–", 0)+1, strpos((#OneUp1.Material.Name), "–", 1))$ 12xy EB The item series between the first and second specified dashes.
Four items after a specified items $SubStrLen((#OneUp1.Material.Name), strpos((#OneUp1.Material.Name), "–", 0)+1, 4)$ 12xy The four symbols after the specified dash.