I\'m looking for a JS method that will turn snake_case
into PascalCase
while keeping slashes intact.
// examples:
post -> Post
a
This should do the trick.
function _snake2Pascal( str ){
str +='';
str = str.split('_');
for(var i=0;i
edit:
a version that passes all your test cases shown in the OP:
function snake2Pascal( str ){
str +='';
str = str.split('_');
function upper( str ){
return str.slice(0,1).toUpperCase() + str.slice(1,str.length);
}
for(var i=0;i