Best way to convert Pascal Case to a sentence

后端 未结 16 1927
天命终不由人
天命终不由人 2020-12-08 13:00

What is the best way to convert from Pascal Case (upper Camel Case) to a sentence.

For example starting with

\"AwaitingFeedback\"

a

16条回答
  •  感情败类
    2020-12-08 13:21

    Pseudo-code:

    NewString = "";
    Loop through every char of the string (skip the first one)
       If char is upper-case ('A'-'Z')
         NewString = NewString + ' ' + lowercase(char)
       Else
         NewString = NewString + char
    

    Better ways can perhaps be done by using regex or by string replacement routines (replace 'X' with ' x')

提交回复
热议问题