programming-examples/js/String/Input a string and converts upper case letters to lower and vice versa.js
2019-11-15 12:59:38 +01:00

6 lines
266 B
JavaScript

swapcase = function swapcase(str) {
return str.replace(/([a-z]+)|([A-Z]+)/g, function(match, chr) {
return chr ? match.toUpperCase() : match.toLowerCase();
});
}
console.log(swapcase('AaBbc'));