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

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

#1

Hi,

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);
console.log(matchedCriminals);

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:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/find-one-or-more-criminals-in-a-hunt


#2

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.


#3

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.


#4

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


#5

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 +


#6

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

cheers!