Last active
October 8, 2015 15:18
-
-
Save ryonsherman/3350420 to your computer and use it in GitHub Desktop.
Various Underscore/CamelCase methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function underscoreToCamelCase(value) { | |
return value.split('_').map(function(value) { return value.charAt(0).toUpperCase() + value.substr(1); }).join(''); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function underscoreToCamelCase($value) { | |
return implode(array_map(function($value) { return ucfirst($value); }, explode('_', $value))); | |
} | |
function camelCaseToUnderscore($value) { | |
return preg_replace_callback('/([A-Z])/', function($char) { return '_'.strtolower($char[1]); }, lcfirst($value)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def underscoreToCamelCase(value): | |
return ''.join([value[0].upper() + value[1:] for value in value.split('_')]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def underscore_to_camelcase(value) | |
value.split('_').map(&:capitalize).join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment