File tree 1 file changed +5
-5
lines changed
Sources/D2Commands/game/tictactoe
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
import Utils
2
2
3
- fileprivate let argsRegex = try ! LegacyRegex ( from : " ( \\ S+) \\ s+( \\ S+) " )
3
+ fileprivate let argsRegex = #/( \\S+)\\s+(\\S+)/#
4
4
5
5
public struct TicTacToeMove : Hashable {
6
6
let row : Int
@@ -12,14 +12,14 @@ public struct TicTacToeMove: Hashable {
12
12
}
13
13
14
14
public init ( fromString str: String ) throws {
15
- if let parsedArgs = argsRegex. firstGroups ( in: str) {
16
- if let row = Row ( rawValue: parsedArgs [ 1 ] ) , let column = Column ( rawValue: parsedArgs [ 2 ] ) {
15
+ if let parsedArgs = try ? argsRegex. firstMatch ( in: str) {
16
+ if let row = Row ( rawValue: String ( parsedArgs. 1 ) ) , let column = Column ( rawValue: String ( parsedArgs. 2 ) ) {
17
17
self . row = row. index
18
18
self . column = column. index
19
- } else if let row = Row ( rawValue: parsedArgs [ 2 ] ) , let column = Column ( rawValue: parsedArgs [ 1 ] ) {
19
+ } else if let row = Row ( rawValue: String ( parsedArgs. 2 ) ) , let column = Column ( rawValue: String ( parsedArgs. 1 ) ) {
20
20
self . row = row. index
21
21
self . column = column. index
22
- } else if let row = Int ( parsedArgs [ 1 ] ) , let column = Int ( parsedArgs [ 2 ] ) {
22
+ } else if let row = Int ( parsedArgs. 1 ) , let column = Int ( parsedArgs. 2 ) {
23
23
self . row = row
24
24
self . column = column
25
25
} else {
You can’t perform that action at this time.
0 commit comments