Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js reg expression pick uppercase

const str = "HERE'S AN UPPERCASE PART of the string";
const upperCaseWords = str.match(/([A-Z][A-Z]+|[A-Z])/g);
// => [ 'HERE', 'S', 'AN', 'UPPERCASE', 'PART' ]
/* - start of the word
  [A-Z] - Any character between capital A and Z
  [A-Z]+ - Any character between capital A and Z, 
   but for one of more times and without interruption
  | - OR
   - start of the word
  [A-Z] - Any character between capital A and Z
   - end of the word
  g - global (run multiple times till string ends, 
      not just for one instance)*/
Source by www.techighness.com #
 
PREVIOUS NEXT
Tagged: #js #reg #expression #pick #uppercase
ADD COMMENT
Topic
Name
7+6 =