Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

String.prototype.swapcase

DZone's Guide to

String.prototype.swapcase

·
Free Resource

String.prototype.swapcase = function(){
	return this.replace(/([a-z])|([A-Z])/g,function($0,$1,$2){
		return ($1) ? $0.toUpperCase() : $0.toLowerCase()
	})
}


"abcdeABCDE".swapcase() => ABCDEabcde
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}