Be the first to rate this file! 31 downloads (last 30 days) File Size: 12.04 KB File ID: #21710

String Toolkits

by Dahua Lin

 

09 Oct 2008 (Updated 10 Oct 2008)

No BSD License  

A set of useful string manipulation functions that MATLAB does not offer

Download Now | Watch this File

File Information
Description

It is a collection of useful string manipulation functions, which offer versatile functionality for joining, splitting, translating strings.

MATLAB is shipped with a series of string functions. However, some useful functions have not yet been in the MATLAB releases. Inspired by other advanced languages like Java, Ruby, and Python, I developed a set of string manipulation functions in order to make string processing more convenient.

Here gives a brief list of contents

strjoin: joins multiple strings with user-specified delimiter

strsplit: extracts terms from a string that are separated by a specified delimiter

strsplit_re: similar to strsplit, but the delimiter is given by regular expression.

strstartswith, strendswith: determine whether a string starts or ends with a particular pattern

strgsub: translates parts of strings in a user-defined way.

This toolbox is not aimed at offering a comprehensive string library and replacing the string functions in MATLAB. Its target is just to complement what MATLAB is lacking. Hope it helps.

MATLAB release MATLAB 7.6 (R2008a)
Zip File Content  
Other Files
strings/.svn/entries,
strings/.svn/format,
strings/.svn/text-base/Contents.m.svn-base,
strings/.svn/text-base/strendswith.m.svn-base,
strings/.svn/text-base/strgsub.m.svn-base,
strings/.svn/text-base/strjoin.m.svn-base,
strings/.svn/text-base/strsplit.m.svn-base,
strings/.svn/text-base/strsplit_re.m.svn-base,
strings/.svn/text-base/strstartswith.m.svn-base,
strings/Contents.m,
strings/strendswith.m,
strings/strgsub.m,
strings/strjoin.m,
strings/strsplit.m,
strings/strsplit_re.m,
strings/strstartswith.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
14 Oct 2008 Jos x@y,z

These are nice but simple wrapper functions for some common tasks. There is sufficient help, but the files could do with some more internal comments.
However, not all functionality is lacking in matlab itself and there are possible suggestions for improvements in the present submission.
1) STRJOIN:
s(1:2:2*numel(terms)) = terms ;
s(2:2:end) = {delimiter} ;
s = [s{:}] ;

2) STRSPLIT has no advantage over TEXTSCAN

3) STRGSUB is akin to STRREP and STRREGEXP; the use of anonymous function in strgsub could benefit from a better description and more examples

15 Oct 2008 Dahua Lin

Thanks for Jos x's comments. I agree that most of the functionality that the toolkit offers can be accomplished with MATLAB's own functions in several lines.

However, when I wrote something related to text processing in MATLAB, I found that these tasks are repeatedly required, and thus it looks cumbersome to repeat those codes again and again, though they are not very long.

Some I organize these tasks into functions and it turns out that they make the text-processing code substantially shorter and more readable.

STRSPLIT actually targets a different situation from textscan. textscan is for finding substrings following some patterns, while strsplit and strsplit_re don't care about each substring's format, and mainly focus on locating the delimiters. They would be sometimes useful when you are intending to extract items from a list.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
strings Dahua Lin 22 Oct 2008 10:23:38
string manipulation Dahua Lin 22 Oct 2008 10:23:38
string processing Dahua Lin 22 Oct 2008 10:23:38
split Dahua Lin 22 Oct 2008 10:23:38
join string Dahua Lin 22 Oct 2008 10:23:38
string Gautam Vallabha 12 Mar 2009 09:55:02
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com