Convert camelCaseText to Sentence Case Text

后端 未结 20 2161
闹比i
闹比i 2020-11-28 03:44

How can I convert a string either like \'helloThere\' or \'HelloThere\' to \'Hello There\' in JavaScript?

20条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 04:24

    Below is link which demonstrates camel case string to sentence string using regex.

    Input

    myCamelCaseSTRINGToSPLITDemo

    Output

    my Camel Case STRING To SPLIT Demo


    This is regex for conversion of camel case to sentence text

    (?=[A-Z][a-z])|([A-Z]+)([A-Z][a-rt-z][a-z]\*)
    

    with $1 $2 as subsitution.

    Click to view the conversion on regex

提交回复
热议问题