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, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 4, 3, 3, 4, 3, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 3, 3, 4, 4, 3, 4, 4, 4, 4, 3, 3, 3, 4, 4, 3, 4, 4, 3, 3, 4, 3, 5, 5, 5, 5, 4, 5, 4, 4, 4)
I have never heard of a parse method to actually parses the string in the way you ask. However, parsing that string is not that hard. Here is how to do it.
string.parse()is designed to be used for (it's used internally as part ofstring.format()). Try taking a look at thereregular expressions library instead.