Determine if a string is collapsible: Difference between revisions

Content added Content deleted
(→‎{{header|Sidef}}: Added Swift solution using Regular Expressions)
Line 1,683: Line 1,683:
]
]


let collapsedStrings = strings.map { $0.replacingOccurrences( of: #"(.)(\1*)"#, with: "$1", options: .regularExpression)}
let collapsedStrings = strings.map { $0.replacingOccurrences( of: #"(.)\1*"#, with: "$1", options: .regularExpression)}


for (original, collapsed) in zip(strings, collapsedStrings) {
for (original, collapsed) in zip(strings, collapsedStrings) {