I'm working on some Swift code to run through an array of strings (teams) and if special characters from another array (charsToRemove) are present, remove the item from the teams array. Alternatively, I'd also be OK with adding items that do NOT contain a special character to an array as well. Here is some sample data:
teams = ["lime", "teal/gold", "red-2", "orange", "orange(6)", "blue-7" ... ]
charsToRemove = [ "(", ")", "-", " ", "/" ... ]
The final result should look like:
teams = ["lime", "orange"]
I've tried a few iterations of loops but looking for what might be the best route. The teams array and special characters is a bit longer but didn't want to paste too much on here.
filter(_:)operation,if specific characters present in swift-> so we need to determine what the predicate is forfilter(_:). From there, people gravitated to either usingArray.contains(_:)orCharacterSet(_:). It's useful to break down problems into sub-problems like this