How to find find groups of uppercase and lowercase characters in a string and replace them this way:
- add html tags for upper case groups:
<span class="upper_group">FOO</span> - add html tags for lower case groups and transform to uppercase:
<span class="lower_group">BAR</span>
I tried this below, but can't transform the lower groups easily to upper case:
let sentence = "NOCH KEt SKUIZh";
let newSentence = sentence.replace(/([a-z]+)/g, '<span class="bar">$1</span>').replace(/([A-Z'.]+)/g, "<span class='foo'>$1</span>");
Expected output:
<span class="foo">NOCH</span> <span class="foo">KE</span><span class="bar">t</span> <span class="foo">SKUIZ</span><span class="bar">h</span>