Question: I'm having troubles with REGEX trying to build one that would retrieve the first letter of a word and any other Capital letter of that word and each first letter including the any Capital letter in the same word

```
"WelcomeBack to NorthAmerica a great place to be" = WBTNAAGPTB
"WelcomeBackAgain to NorthAmerica it's nice here" = WBATNAINH
"Welcome to the NFL, RedSkins-Dolphins play today" = WTTNFLRSDPT

```

tried this juus to get the first 2 matches: 

```
/([A-Z])|\b([a-zA-Z])/g

```

Any help is welcomed, thanks

Answer: 
You need a regex that will match all uppercase letters and those lowercase letters that appear at the start of the string or after a whitespace:

```js
var re = /[A-Z]+|(?:^|\s)([a-z])/g; 
var strs = ["WelcomeBack to NorthAmerica a great place to be", "WelcomeBackAgain to NorthAmerica it's nice here", "Welcome to the NFL, RedSkins-Dolphins play today"];
for (var s of strs) {
  var res = "";
  while((m = re.exec(s)) !== null) {
    if (m[1]) {
       res += m[1].toUpperCase();
    } else {
      res += m[0];
    }
  }
  console.log(res);
}
```

Here, `[A-Z]+|(^|\s)([a-z])` matches multiple occurrences of:

* `[A-Z]+` - 1 or more uppercase ASCII letters
* `|` - or
* `(?:^|\s)` - start of string (`^`) or a whitespace (`\s`)
* `([a-z])` - Group 1: one lowercase ASCII letter.
You can try this, it will also take care of whitespaces 

```
str = str.match(/([A-Z])|(^|\s)(\w)/g);
str = str.join('');
str=str.replace(/ /g,'');
return str.toUpperCase();

```