Codewars Challenge Day2: Break camelCase

Name Kata: Break camelCase / 6kuy

Details

Complete the solution so that the function will break up camel casing, using a space between words.

Example

'camelCase' -> 'camel Case'

My Solutions

JavaScript

const solution = (str) => {
return str.split(/\s+|\_+|(?=[A-Z])/gm).join(' ')
}

Python

def solution(string: str) -> str:
res = ''
for symbol in string:
if symbol.upper() == symbol:
res = res + ' ' + symbol
else:
res = res + symbol
return res

原文链接:Codewars Challenge Day2: Break camelCase

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
Be happy. No worries, just smile.
开心点,别担心,微笑就好
评论 抢沙发

请登录后发表评论

    暂无评论内容