Split String into Array of subarrays : <p>This question is related to my <a href="https://stackoverflow.com/questions/55396179/split-string-into-array-of-arrays">Previous question</a></p>

<p>I am writing an iOS App in Swift 4.2</p>

<p>Response from server is a string with values separated by pipe character "". It contains many rows of values separated by "$". I want to split it into array of subarrays.</p>

<p>Rows are separated by "<strong>$</strong>" and elements are separated by "<strong>|</strong>"</p>

<p>Response:</p>

<p>Example: <strong>"001|apple|red$002|banana|yellow$003|grapes|purple$"</strong></p>

<p><strong>Expected Output:</strong></p>

<p>[[001, "apple", "red"], [002, "banana", "yellow"], [003, "grapes", "purple"]]</p>
