In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!
Change the casing in a following way:
- If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
- If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
- In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.
- A to Z
- a to z
- underscore (
Input with mixed cased words are disallowed. Examples of disallowed cases:
Input | Expected Output =========================================================== CodingConventionConversion | coding_convention_conversion coding_convention_conversion | CodingConventionConversion abc | Abc Abc | abc ABC | a_b_c a_b_c | ABC a | A A | a
- It is allowed to use
- Using regular expressions is allowed.
- code-golf: shortest code in bytes wins!