I want to generate an abbreviation string like 'CMS' from the string 'Content Management Systems', preferably with a regex.
Is this possible using JavaScript regex or should I have to go the split-iterate-collect?
Capture all capital letters following a word boundary (just in case the input is in all caps):
var abbrev = 'INTERNATIONAL Monetary Fund'.match(/\b([A-Z])/g).join('');
alert(abbrev);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With