File Exchange

image thumbnail

Line-wrap a string

version 1.0.0.1 (2.16 KB) by

Break a string into multiple lines

11 Downloads

Updated

View License

The function linewrap.m wraps a single string into multiple lines by breaking it at word boundaries. The user can specify the desired maximum number of characters per line.

Comments and Ratings (6)

Yas

Yas (view profile)

Daniel Golden

Christine A.

Very useful, thanks for sharing

matt dash

matt dash (view profile)

urs (us) schwarz

for users: a great little helper that wraps your endless line into a nice little parcel (command line output/uicontrols)...
for programmers: look at the remarkable regular expression...
us

urs (us) schwarz

nice exercise with regular expressions, it will get a 5/5 if it handles multiple white-spaces more consistently, eg, with a final DEBLANK(?)
moreover, a pointer to TEXTWRAP, which implements an only slightly different engine, would be nice
us

Updates

1.0.0.1

Updated license

Implemented suggestions from Urs: Use strtrim on the input string to remove leading and trailing whitespace; use deblank on output array to remove trailing whitespace; add cross-reference to textwrap.

MATLAB Release
MATLAB 7.1.0 (R14SP3)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video