Closed
Description
The first regex runs instantly as expected, but the second one appears to run forever. The first has @
in the alternation while the second has it outside as an anchor.
Running them on regex101 shows that their engines run the two regexes in a similar number of cycles and match the same results.
func testInfiniteLoop() {
print("Starting regex")
// let regex = try! Regex(#"(?:\d|\w|\.|-|_|%|\+|@)+"#)
let regex = try! Regex(#"(?:\d|\w|\.|-|_|%|\+|)+@(?:\d|\w|\.|-|_|%|\+|)+"#)
print(try! regex.firstMatch(in: "[email protected]"))
print("Finished regex")
}
Metadata
Metadata
Assignees
Labels
No labels