Created
August 12, 2022 07:47
-
-
Save eunjin3786/1c3a797ffb2191da4ee7c8d56b35a09a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RegexBuilder | |
let regex = Regex { | |
"Hi, WWDC" | |
Repeat(.digit, count: 2) | |
"!" | |
} | |
let input = "Hi, WWDC21! Hi, WWDC22! Hi Hello" | |
let match1 = try regex.firstMatch(in: input)?.output // Hi, WWDC21! | |
let match2 = input.firstMatch(of: regex)?.output // Hi, WWDC21! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment