File Exchange

image thumbnail


version (9.18 KB) by David Fass
Convert a string to "headline" format (initial capitals on key words).

1 Download

Updated 31 Mar 2016

View License

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:


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.


Comments and Ratings (0)


Update for BSD license.

Bug fix.

Bug fix: Function changed caps on prepositions occuring as part of other words, i.e., "the" in "theory". Hopefully this won't happen anymore.

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor