Code covered by the BSD License  

Highlights from
Case Converter

4.5

4.5 | 2 ratings Rate this file 6 Downloads (last 30 days) File Size: 2.58 KB File ID: #6275

Case Converter

by Skynet

 

15 Nov 2004 (Updated 10 Jun 2005)

Converts character string case to title, sentence, toggle, random, upper, or lower case.

| Watch this File

File Information
Description

This function uses mostly the 'upper' and 'lower' functions to convert a text string to additional case types including 'Title Case', 'Sentence case', 'tOGGLE cASE', and 'RaNDoMizEd cASe'.

Type 'help caseconvert' for usage details.

Examples:

caseconvert('sample text','title') returns 'Sample Text'
caseconvert('Sample Text','toggle') returns 'sAMPLE tEXT'

caseconvert({'new york' 'california'},'randomized')
returns {'neW yoRk' 'CAlIFORnIA'}

caseconvert({'This Is A Test.' 'Matlab'},{'sentence' 'upper'})
returns {'This is a test.' 'MATLAB'}

[Please subscribe to this file if you use it, so you can be notified of updates.]

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
18 Jan 2006 John D'Errico

Nice idea. I noted that 'sentence' only catches the first character in the FIRST sentence. So if you have a string with two sentences, it misses the second. I'd also prefer to see error checking on the second argument. Even better is to allow the user to shorten the second argument, as long as this can be done unambiguously. Strmatch or strncmpi can help you to find the correct match. Thus allow upper to be shortened as 'upp' or even 'u'. 'title' or 'toggle' could be shortened only to 'ti' or 'to' respectively.

03 Aug 2007 Carlos Lopez

I managed to remove all references to function isstrprop, allowing the stuff to run also for version 6.5. Remove the obvious _000_ from the e-mail to request a copy.

21 May 2010 Kevin J. Delaney

Fantastic--just what I was looking for!

Please login to add a comment or rating.
Updates
17 Nov 2004

Fixed bug so "jane's" in 'title' case changes to "Jane's" instead of "Jane'S".

22 Nov 2004

Fixed bug so "jane's" in 'title' case changes to "Jane's" instead of "Jane'S".

29 Nov 2004

Updated code design to use the 'switch' and 'case' functions instead of 'if' statements.

29 Dec 2004

Added support for char and cell arrays.

07 Jun 2005

Vectorized two 'for' loops, and made minor comment updates.

10 Jun 2005

Made a few minor changes as suggested by M-Lint.

Tag Activity for this File
Tag Applied By Date/Time
strings Skynet 22 Oct 2008 07:35:47
case Skynet 22 Oct 2008 07:35:47
case convert Skynet 22 Oct 2008 07:35:47
case conversion Skynet 22 Oct 2008 07:35:47
proper Skynet 22 Oct 2008 07:35:47
upper Skynet 22 Oct 2008 07:35:47
title case Skynet 22 Oct 2008 07:35:47
lower Skynet 22 Oct 2008 07:35:47
upper OTACILIO FERREIRA 09 May 2011 15:28:25

Contact us at files@mathworks.com