source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/globstrings.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.0 KB
Line 
1function results = globstrings(patterns, strs);
2%GLOBSTRINGS  String matching via wildcards.
3% GLOBSTRINGS(PATTERNS,STRINGS) returns a cell array of the strings from
4% STRINGS that match some wildcard pattern in PATTERNS.
5% STRINGS is a cell array of strings.
6% PATTERNS is a string or cell array of strings.
7%
8% Two types of wildcards are supported:
9% * matches zero or more characters.
10% ? matches exactly one character.
11%
12% Examples:
13%   globstrings('f?*r',{'fr','fur','four'})   % returns {'fur','four'}
14%   globstrings({'a*','*c'},{'ace','bar','rac'}) % returns {'ace','rac'}
15%
16% See also glob, glob2regexp.
17
18% Written by Tom Minka
19% (c) Microsoft Corporation. All rights reserved.
20
21if ischar(patterns)
22  patterns = cellstr(patterns)';
23end
24patterns = patterns;
25results = {};
26for i = 1:length(patterns)
27  s = regexp(strs,glob2regexp(patterns{i}),'match');
28  s = cat(2,s{:});
29  if isempty(s)
30    warning([patterns{i} ' did not match anything']);
31  else
32    results = {results{:} s{:}};
33  end
34end
Note: See TracBrowser for help on using the repository browser.