@@ -10,23 +10,23 @@ GitHub launched in 2018-04-10.`;
1010 const inputPatterns = [
1111 "git" , // => /git/g
1212 "/github/i" , // => /github/ig
13- "/\\d{4}- \\d{2}- \\d{2}/" // => /\d{4}-\d{2}-\d{2}/g
13+ "/( \\d{4})-( \\d{2})-( \\d{2}) /" // => /\d{4}-\d{2}-\d{2}/g
1414 ] ;
1515
1616 const results = matchPatterns ( inputText , inputPatterns ) ;
1717 assert . deepStrictEqual ( results , [
18- { match : "GitHub" , startIndex : 1 , endIndex : 7 } ,
19- { match : "git" , startIndex : 65 , endIndex : 68 } ,
20- { match : "GitHub" , startIndex : 107 , endIndex : 113 } ,
21- { match : "2018-04-10" , startIndex : 126 , endIndex : 136 }
18+ { match : "GitHub" , startIndex : 1 , endIndex : 7 , captures : [ ] } ,
19+ { match : "git" , startIndex : 65 , endIndex : 68 , captures : [ ] } ,
20+ { match : "GitHub" , startIndex : 107 , endIndex : 113 , captures : [ ] } ,
21+ { match : "2018-04-10" , startIndex : 126 , endIndex : 136 , captures : [ "2018" , "04" , "10" ] }
2222 ] ) ;
2323} ) ;
2424
2525it ( "RegExp-like string" , ( ) => {
2626 const inputText = `This is a pen.` ;
2727 // RegExp like strings
28- const inputPatterns = [ "/a \\w+/" ] ;
28+ const inputPatterns = [ "/a ( \\w+) /" ] ;
2929
3030 const results = matchPatterns ( inputText , inputPatterns ) ;
31- assert . deepStrictEqual ( results , [ { match : "a pen" , startIndex : 8 , endIndex : 13 } ] ) ;
31+ assert . deepStrictEqual ( results , [ { match : "a pen" , startIndex : 8 , endIndex : 13 , captures : [ "pen" ] } ] ) ;
3232} ) ;
0 commit comments