List of utility methods to do String Case Convert
snake_case()String.prototype.snake_case = function(){ return this .replace( /[A-Z]/g, function($1) { return '_' + $1 } ) .toLowerCase(); | |
toSnakeCase()String.prototype.toSnakeCase = function(){ return this.replace(/([A-Z])/g, function($1){return "_"+$1.toLowerCase();}); }; | |
toCap()String.prototype.toCap = function () { var result = this.toUpperCase().charAt(0) + this.slice(1, this.length); return result; }; | |
toCap()String.prototype.toCap = function() { var string = this.toString(); if(!string.length) return; var lastName = string.split(' ').pop(); var firstName = string.split(' ')[0]; lastName = lastName[0].toUpperCase() + lastName.slice(1); firstName = firstName[0].toUpperCase() + firstName.slice(1); string = firstName + " " + lastName; return string; ... | |
toCap()'use strict' export default (obj) => String.prototype.toCap.apply(obj) String.prototype.toCap = function () { return this.toUpperCase().charAt(0) + this.slice(1,(this.length)); |