To start, the challenge specifies I need to make an extension on string, so I will set that up. Then, since we are ignoring case, I will go ahead and create lowercased versions of both the string passed in and self. I will then see about using regular expressions to determine if self contains the string passed in.
Ok, so turns out, the .rangeOf function has an options parameter which could allow us to use a regular expression, or simply specify .caseInsensitive. So this challenge is solved in one line. Kinda lame. Maybe come up with a harder challenge that forces us to use a regular expression...
extension String {
func anotherContains(_ string: String) -> Bool {
self.range(of: string, options: .caseInsensitive) != nil
}
}
print("Where is WaLdO".anotherContains("WALDO")) // true
print("Where is WaLdO".anotherContains("Shawn")) // false