headline
HEADLINE Convert string to "headline" format (initial capitals on key words).
B = HEADLINE(A) converts the initial letter of all words (except prepositions and conjunctions) in A to capitals. A must be a string. Any letters placed in curly braces "{}" will be left unaltered (i.e., in their original case).
B = HEADLINE, with no inputs, produces the default list of prepositions and conjunctions that are not capitalized. This list can be modified using the following syntax:
B = HEADLINE(...,addList,delList) adds the words in cell array addList to the default list of of words, and deletes the words in cell array delList from the default list of of words. Use empty brackets [] for addList if you wish only to specify delList. (The function does not check whether added words already exist on the list, since this would be unnecessary computation. Words to be deleted must match entries in the default list exactly.)
The default list of prepositions can also be modified simply by editing the M-file. The default list has been extracted from the Wikipedia entry for English Prepositions:
http://en.wikipedia.org/wiki/List_of_English_prepositions
Examples:
A = 'life, don''t talk to me about life.'
y = headline(A)
y =
Life, Don't Talk to Me about Life.
y = headline(A,'don''t')
y =
Life, don't Talk to Me about Life.
y = headline(A,'don''t','about')
y =
Life, don't Talk to Me About Life.
B = '{l}ife, don''t talk to {me} about life.'
y = headline(B)
y =
life, Don't Talk to me about Life.
See also UPPER, LOWER, INITIALCAPS.
Cite As
David Fass (2024). headline (https://www.mathworks.com/matlabcentral/fileexchange/12433-headline), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Language Fundamentals > Data Types > Tables >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Bug fix.
|