[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Search string in cell string?
From: |
William Krekeler |
Subject: |
RE: Search string in cell string? |
Date: |
Tue, 6 Dec 2011 17:20:13 +0000 |
-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Jordi Gutiérrez Hermoso
Sent: Tuesday, December 06, 2011 10:54 AM
To: Octave-help
Subject: Search string in cell string?
How can you get the index of where in a cell string a specified search
term occurs, if it does at all?
Assuming the cell string were ordered, you could binary search. But
how can you compare strings ASCIIbetically? The strcmp function only
gives you equality or not, not order.
So what can be done?
- Jordi G. H.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
Jordi,
It took me awhile to figure this out some time ago. You may have to modify a
little for you application. Example, depending upon your input the {} may not
be needed. Note, this works in ML, I'm pretty sure it should also work in
Octave.
indexes = find( cellfun( 'isempty', regexpi( {cellStringArray}, matchString ) )
== 0 );
William Krekeler