2009-02-04 115 views

回答

6

MDC索赔,你可以做到这一点:

function styleHyphenFormat(propertyName) 
{ 
    function upperToHyphenLower(match) 
    { 
    return '-' + match.toLowerCase(); 
    } 
    return propertyName.replace(/[A-Z]/, upperToHyphenLower); 
} 

或者更一般地:

myString.replace(/mypattern/g, function(match){ 
    return "Some function of match"; 
}); 
+0

MDC是我的第一个选择,但是当我试图看到时,它已经停止。我发现的其他网站只有简单的替换例子。 – Slartibartfast 2009-02-04 18:36:29