Capitalize strings using titlecase

Capitalize the first letter of each word in a string or cell array of strings
542.0 次下载
更新时间 2013/9/23

查看许可证

This function capitalizes each word in a string, or in a cell array of strings, excepting a user-definable set of short words. The default non-capitalized words are 'a', 'an', 'and', 'or', 'the', and 'in'.

Example:

>> C={'a walk in the park' 'two birds with one stone' 'pay the piper'}';
>> capitalize(C)

ans =

'A Walk in the Park'
'Two Birds With One Stone'
'Pay the Piper'

>> capitalize(C,{'with','THE'})

ans =

'A Walk In the Park'
'Two Birds with One Stone'
'Pay the Piper'

>>

引用格式

Brandon Kuczenski (2024). Capitalize strings using titlecase (https://www.mathworks.com/matlabcentral/fileexchange/43399-capitalize-strings-using-titlecase), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2011b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.1.0.0

Corrected silly error that caused the function to fail for single-word inputs.

1.0.0.0