Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: String manipulation
Date: Tue, 2 Apr 2013 15:01:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <kjerri$58n$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1364914866 5399 172.30.248.37 (2 Apr 2013 15:01:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 2 Apr 2013 15:01:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4199643
Xref: news.mathworks.com comp.soft-sys.matlab:792487

I have a cell array of strings that I need to extract substrings from based on the location of hyphens. the array is something like this:
str = {'*88-123-*-001*';
         '*88-124-*-001*';
         '*88-125-*-001*';
         '*88-126-*-001*'}

where the * can be any number of characters. I am trying to extract just the numbers. If the strings were the same length identification of the first hyphen and last hyphen could occur followed by conversion to char. 

str2=char(str);
hyphs = cell2mat(strfind(str,'-'));
out = cellstr(strcat(str2(:,hyphs(1)-2:hyphs(:,1)+3),str2(:,hyphs(end)+1:hyphs(end)+3)));

However with different lengths the indices of the hypens will change from row to row and that wont work properly. I would think there is a way to do this without a forloop but I cant think of it. Any suggestions, Thnx