Help with Greedy Matching - Criminal Challenge

Find Criminals in a Hunt

let reCriminals = /.*C+.*/;  // Why would this code not work instead of
let reCriminals = /C+/;  //  this one?

this will match anything that contains at least one C, as in, the whole string

like, if you try with the test cases:

Your regex should match five criminals (CCCCC ) in the string P6P2P7P4P5CCCCCP3P1

const str = "P6P2P7P4P5CCCCCP3P1";
const re = /.*C+.*/
const output = str.match(re);


it matches the whole string. You want something that matches only the various characters C

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.