将字符串转换成句子,即只有第一个单词的首字母为大写,头部和尾部没有空格,单词分界为一个空格。
处理传入的字符串时,下划线和破折号也被看作是单词分界。
- Source:
Example
str.humanize('the_humanize_string_method') // 'The humanize string method'
str.humanize('ThehumanizeStringMethod') // 'Thehumanize string method'
str.humanize('-ThehumanizeStringMethod') // 'Thehumanize string method'
str.humanize('the humanize string method ') // 'The humanize string method'
str.humanize('the humanize_id string method') // 'The humanize id string method'
Parameters:
Name | Type | Description |
---|---|---|
str |
String | 需转换成句子的字符串 |
Returns:
已转换成句子的字符串
- Type
- String