Find One or More Criminals in a Hunt--

Tell us what’s happening:
I tried all the options but I can’t get the challenge right

Your code so far

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

let reCriminals = /[^.]c*/i; // Change this line

let matchedCriminals = crowd.match(reCriminals);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

First, [^.] means ‘match any character other than a character’, which doesn’t make sense. Omit it.

Second, criminals are denoted by ‘C’ not ‘c’. So you can use ‘C’ and remove the ‘i’ tag which ignores the letter case.

Third, you are supposed to match one or more criminals ©, so the ‘+’ character is required (not ‘*’).

Last, since the criminals may not all be next to each other, you need to search for all groups. This is done by adding a ‘g’ (global) tag.

For more on regexp check out

1 Like

Thanks alot @joops75

Actually, [^.] means ‘match any character other than a dot’. Outside of square brackets, ‘.’ means ‘any character’. Inside them, it means itself, ‘.’ (dot).