How can I split the given String
in Swift into groups with given length, reading from right to left?
For example, I have string 123456789
and group length of 3. The the string should be divided into 3 groups: 123
, 456
, 789
. String 1234567
will be divided into 1
, 234
, 567
So, can you write some nice code in Swift:
func splitedString(string: String, length: Int) -> [String] {
}
BTW tried function split()
, but as I understand it works only with finding some symbol