someString.substring(with: someRange)
should be someString[someRange]
.
So change:
entity.substring(with: entity.index(entity.startIndex, offsetBy: 3) ..< entity.index(entity.endIndex, offsetBy: -1))
with
entity[entity.index(entity.startIndex, offsetBy: 3) ..< entity.index(entity.endIndex, offsetBy: -1)]
In other words, change the value .substring(with:
to [
and change the closing value )
to ]
.
The result is Substring
, not String
. Therefore, you may need to wrap the result in String( )
to get String
substrings from the result.
source
share