[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Search string in cell string?
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: Search string in cell string? |
Date: |
Tue, 6 Dec 2011 12:44:23 -0500 |
2011/12/6 William Krekeler <address@hidden>:
> 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 );
Well, for this approach, this also works:
idx = find(cellfun(@(x) strcmp(x, match_string), cell_string))
which seems simpler to me. However, I should have been more specific.
Suppose you have a large ordered dictionary, where binary search is
possible. How can you do binary search with strings?
- Jordi G. H.