是否可以將駱駝大小寫字符串解析爲更具可讀性的內容。如何解析駱駝案例人類可讀的字符串?
例如:
- LocalBusiness =本地商戶
- CivicStructureBuilding =文娛結構建築
- getUserMobilePhoneNumber =獲取用戶手機號碼
- bandGuitar1 =樂隊吉他1
UPDATE
使用正則表達式simshaun例如我設法從文本與本規則分開編號:
function parseCamelCase($str)
{
return preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]|[0-9]{1,}/', ' $0', $str);
}
//string(65) "customer ID With Some Other JET Words With Number 23rd Text After"
echo parseCamelCase('customerIDWithSomeOtherJETWordsWithNumber23rdTextAfter');
感謝,但它是可以分離的數字? – Nazariy 2011-06-06 15:17:23
當然可以。編輯。 – simshaun 2011-06-06 15:34:18
@dynamic ...有什麼建議嗎? – greaterKing 2015-01-04 05:08:15