camelize方法,轉換爲駝峯命名風格:javascript
function camelize (target) { if (target.indexOf('_') < 0 && target.indexOf('_') < 0) return target; return target.replace(/[-_][^-_]/g , function(match){ return match[1].toUpperCase(); }) }
underscored方法,轉換爲下劃線風格:java
function underscored(target){ return target.replace(/([a-z\d])([A-Z])/g , '$1_$2').replace(/\-/g , '_').toLowerCase(); }