Find One or More Criminals in a Hunt - please explain what to write


I have trouble understanding this challenge. Could someone explain to me how should I write the regex?

// example crowd gathering
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';

let reCriminals = /.c+/ig; // Change this line

let matchedCriminals = crowd.match(reCriminals);

Browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:

1 Like

You’re really close to the solution. Just think about what it is that you’re actually looking up in /.c+/ig.

The . is a wildcard. Think about it.

1 Like

the most crucial hint I found doing it, was this line…

The regex /z+/ matches the letter z when it appears one or more times in a row.

I see then that dot was unnecessary. It should be C+. Thanks for tips.

1 Like

It will be [C.C*]+
here First C will Search for first C than . will look for another letter so make another letter C and Repeat it.Finally contain whole word with +

you can achieve the same solution with this expresion: /[C]+/g


/C+.*?/ worked for me