general info https en wikipedia orgwikinamingconventionprogrammingpythonandruby pascal case an upper camel case https en wikipedia orgwikicamelcase camel case https en wikipedia orgwikicamelcase kebab case can be found in general info https en wikipedia orgwikinamingconventionprogrammingpythonandruby snake case https en wikipedia orgwikisnakecase assistant functions splitinputone two 31235three4four one two 31235three4four tosimplecaseone two 31235three4four onetwo31235three4four tosimplecasethis should be combined thisshouldbecombined tosimplecasethe first letters are capitalized then string is merged thefirstlettersarecapitalizedthenstringismerged tosimplecasespecial characters are ignored specialcharactersareignored returns the string concatenated with the delimiter we provide parameters text the string on which we want to perform operation upper boolean value to determine whether we want capitalized result or not separator the delimiter with which we want to concatenate words examples tocomplexcaseone two 31235three4four true onetwo31235three4four tocomplexcaseone two 31235three4four false onetwo31235three4four main content topascalcaseone two 31235three4four onetwo31235three4four tocamelcaseone two 31235three4four onetwo31235three4four tosnakecaseone two 31235three4four true onetwo31235three4four tosnakecaseone two 31235three4four false onetwo31235three4four tokebabcaseone two 31235three4four true onetwo31235three4four tokebabcaseone two 31235three4four false onetwo31235three4four general info https en wikipedia org wiki naming_convention_ programming python_and_ruby pascal case an upper camel case https en wikipedia org wiki camel_case camel case https en wikipedia org wiki camel_case kebab case can be found in general info https en wikipedia org wiki naming_convention_ programming python_and_ruby snake case https en wikipedia org wiki snake_case assistant functions split_input one two 31235three4four one two 31235three4four to_simple_case one two 31235three4four onetwo31235three4four to_simple_case this should be combined thisshouldbecombined to_simple_case the first letters are capitalized then string is merged thefirstlettersarecapitalizedthenstringismerged to_simple_case special characters are ignored specialcharactersareignored returns the string concatenated with the delimiter we provide parameters text the string on which we want to perform operation upper boolean value to determine whether we want capitalized result or not separator the delimiter with which we want to concatenate words examples to_complex_case one two 31235three4four true _ one_two_31235three4four to_complex_case one two 31235three4four false one two 31235three4four main content to_pascal_case one two 31235three4four onetwo31235three4four to_camel_case one two 31235three4four onetwo31235three4four to_snake_case one two 31235three4four true one_two_31235three4four to_snake_case one two 31235three4four false one_two_31235three4four to_kebab_case one two 31235three4four true one two 31235three4four to_kebab_case one two 31235three4four false one two 31235three4four
import re





def split_input(str_: str) -> list:
    
    return [char.split() for char in re.split(r"[^ a-z A-Z 0-9 \s]", str_)]


def to_simple_case(str_: str) -> str:
    
    string_split = split_input(str_)
    return "".join(
        ["".join([char.capitalize() for char in sub_str]) for sub_str in string_split]
    )


def to_complex_case(text: str, upper: bool, separator: str) -> str:
    
    try:
        string_split = split_input(text)
        if upper:
            res_str = "".join(
                [
                    separator.join([char.upper() for char in sub_str])
                    for sub_str in string_split
                ]
            )
        else:
            res_str = "".join(
                [
                    separator.join([char.lower() for char in sub_str])
                    for sub_str in string_split
                ]
            )
        return res_str
    except IndexError:
        return "not valid string"



def to_pascal_case(text: str) -> str:
    
    return to_simple_case(text)


def to_camel_case(text: str) -> str:
    
    try:
        res_str = to_simple_case(text)
        return res_str[0].lower() + res_str[1:]
    except IndexError:
        return "not valid string"


def to_snake_case(text: str, upper: bool) -> str:
    
    return to_complex_case(text, upper, "_")


def to_kebab_case(text: str, upper: bool) -> str:
    
    return to_complex_case(text, upper, "-")


if __name__ == "__main__":
    __import__("doctest").testmod()