Skip to content

Commit

Permalink
Made String.regex* methods more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Feb 27, 2021
1 parent 40fdad0 commit 3a7371c
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ class Extensions_Foundation_StringAndNSRegularExpression_Tests: XCTestCase {

func testRegExCaptureGroups() {

let capturePattern = """
([a-zA-z\\s]*)\\s([0-9]+)\\s([a-zA-z\\s]*)\\s([0-9]+)\\s([a-zA-z\\s.]*)
"""
let capturePattern = #"""
([a-zA-z\s]*)\s([0-9]+)\s([a-zA-z\s]*)\s([0-9]+)\s([a-zA-z\s.]*)
"""#

let str = "The 45 turkeys ate 9 sandwiches."

XCTAssertEqual(str.regexMatches(captureGroupsFromPattern: capturePattern),
[Optional("The"),
[Optional("The 45 turkeys ate 9 sandwiches."),
Optional("The"),
Optional("45"),
Optional("turkeys ate"),
Optional("9"),
Expand Down

0 comments on commit 3a7371c

Please sign in to comment.