File Exchange

image thumbnail

Line-wrap a string

version 1.0.0.1 (2.16 KB) by Steve Eddins
Break a string into multiple lines

4 Downloads

Updated 01 Sep 2016

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.

Cite As

Steve Eddins (2020). Line-wrap a string (https://www.mathworks.com/matlabcentral/fileexchange/9909-line-wrap-a-string), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Very very good! Nice job!

Yas

Very useful, thanks for sharing

matt dash

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

1.0.0.0

Update keywords and description to make it easier to find this file via search.

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 Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux