Code covered by the BSD License  

Highlights from
Line-wrap a string

5.0

5.0 | 4 ratings Rate this file 13 Downloads (last 30 days) File Size: 2.16 KB File ID: #9909

Line-wrap a string

by Steve Eddins

 

06 Feb 2006 (Updated 06 Mar 2006)

Break a string into multiple lines

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
07 Feb 2006 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

08 Feb 2006 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

06 Mar 2009 matt dash  
27 Nov 2010 Christine Acou

Very useful, thanks for sharing

Please login to add a comment or rating.
Updates
08 Feb 2006

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.

06 Mar 2006

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

Tag Activity for this File
Tag Applied By Date/Time
strings Steve Eddins 22 Oct 2008 08:15:00
string line wrap linewrap Steve Eddins 22 Oct 2008 08:15:00
string line wrap linewrap Mircea Ionescu 12 Apr 2010 13:26:19
string line wrap linewrap Onomitra Ghosh 22 Sep 2011 11:24:49
string line wrap linewrap Wouter Numan 27 Jan 2012 05:57:41

Contact us at files@mathworks.com