showing results for - "js reg expression pick uppercase"
Emilia
06 Sep 2020
1const str = "HERE'S AN UPPERCASE PART of the string";
2const upperCaseWords = str.match(/(\b[A-Z][A-Z]+|\b[A-Z]\b)/g);
3// => [ 'HERE', 'S', 'AN', 'UPPERCASE', 'PART' ]
4/*\b - start of the word
5  [A-Z] - Any character between capital A and Z
6  [A-Z]+ - Any character between capital A and Z, 
7   but for one of more times and without interruption
8  | - OR
9  \b - start of the word
10  [A-Z] - Any character between capital A and Z
11  \b - end of the word
12  g - global (run multiple times till string ends, 
13      not just for one instance)*/
14