Path: news.mathworks.com!not-for-mail
From: "jay vaughan" <jvaughan5.nospam@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matching Character Phrases...
Date: Fri, 22 Feb 2008 02:47:07 +0000 (UTC)
Organization: harvard
Lines: 41
Message-ID: <fpld3b$s94$1@fred.mathworks.com>
References: <fpkn42$3cg$1@fred.mathworks.com> <fpkp21$rvm$1@fred.mathworks.com> <fpktm4$501$1@fred.mathworks.com>
Reply-To: "jay vaughan" <jvaughan5.nospam@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203648427 28964 172.30.248.35 (22 Feb 2008 02:47:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 22 Feb 2008 02:47:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1215048
Xref: news.mathworks.com comp.soft-sys.matlab:453044



Hmm, is the length of the repeated strings always known? In 
your case it seemed to be 4.

J

"Jack Branning" <jbr.nospam@nospam.com> wrote in message 
<fpktm4$501$1@fred.mathworks.com>...
> "jay vaughan" <jvaughan5.nospam@gmail.com> wrote in 
message 
> <fpkp21$rvm$1@fred.mathworks.com>...
> > I recently learned a little about regexp, and you might 
try 
> > something like the following. You could use the 
> > outputs 'num_times' and 'distances' to format the 
output 
> > exactly how you want it. No loop required.
> > 
> > J
> > 
> > A 
= 'OPASKSGLBOJASLOPASNKMGLBOSDLASJSFLOPASHHASKSMLGLBO';
> > user_str = 'OPAS';
> > [s] = regexp(A,user_str,'start');
> > num_times = size(s,2);
> > distances = diff(s);
> > 
> 
> 
> Thanks for your help, that's definitely along the right 
lines, although I need 
> the program to be finding the phrases itself.  So, for 
example, it firstly tries to 
> find all 'OPAS' matches in 'text' (A, in your example), 
then moves on to 'PASK' 
> matches, then 'ASKS' etc, until it has found 30 matches, 
or it reaches the end 
> of the 'text'.
> 
> 
>