I have a string "323 ECO Economics Course 451 ENG English Course 789 Mathematical Topography"
I want to split this string using the regex expression [0-9][0-9][0-9][A-Z][A-Z][A-Z]
so that the function returns the array:
Array =
["323 ECO Economics Course ", "451 ENG English Course", "789 Mathematical Topography"]
How would I go about doing this using swift?
Edit
My question is different than the one linked to. I realize that you can split a string in swift using myString.components(separatedBy: "splitting string")
The issue is that that question doesn't address how to make the splitting string
a regex expression. I tried using mystring.components(separatedBy: "[0-9][0-9][0-9][A-Z][A-Z][A-Z]", options: .regularExpression)
but that didn't work.
How can I make the separatedBy:
portion a regular expression?