🎯
Focusing
Pinned Loading
-
-
-
"Grab The City" is a challenge that ...
"Grab The City" is a challenge that wants you to extract the name of the city in a given sentence which the name is wrapped in a pair of square brackets in the end of the sentence. 1func grabCity(_ str: String) -> String {
2// the commented line below (the regex to be exact) gets just the last word! which is wrong, my fault though, i didn't read the challenge corectly!
3// let regex = try! NSRegularExpression(pattern: "(\\w+)(?!.*\\w)", options: [])
4// the regex below get every matches in the sentence that is being wrapped in a pair of square brackets.
5let regex = try! NSRegularExpression(pattern: "(?<=\\[)(.+?)(?=\\])", options: [])
-
-
-
Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.
If the problem persists, check the GitHub status page or contact support.