Vous suivez désormais cette soumission
- Les mises à jour seront visibles dans votre flux de contenu suivi
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails
IS_STR_IN_STR finds whether a string (or elements of a cell-array of strings) contains at least one of a specified sub-string (or any of the elements of a cell-array of sub-strings).
L = IS_STR_IN_STR(X,PATTERN) returns a logical the same size as X indicating whether the pattern is in X.
X can be a string or cell-array of strings.
PATTERN can be a string*, cell-array of strings*, or a regular expression.
* Warning: REGEXP is used to find the occurences of strings so, for these, PATTERN should not include any regexp control characters (e.g. | or \ etc.).
L = IS_STR_IN_STR(X,PATTERN,TRUE) does the comparison as case-sensitive (otherwise the default is case-insensitive).
Example use:
cell_test = {'Black cat'; 'Cat and Dog'; 'white dog'; 'black dog'; 'blue bird'}
idx1 = is_str_in_str(cell_test, 'DOG');
idx2 = is_str_in_str(cell_test, 'dog', 1); %Case sensitive
idx3 = is_str_in_str(cell_test, {'black', 'blue'}); % Find cells with black OR blue
idx4 = is_str_in_str(cell_test, 'bla|blue'); % Find cells with black OR blue (specified via a regular expression).
[cell_test num2cell([idx1 idx2 idx3 idx4])]
Citation pour cette source
Roger Parkyn (2026). is_str_in_str(c, str_match, is_case_sensitive) (https://fr.mathworks.com/matlabcentral/fileexchange/52175-is_str_in_str-c-str_match-is_case_sensitive), MATLAB Central File Exchange. Extrait(e) le .
Informations générales
- Version 1.1.0.0 (2,44 ko)
Compatibilité avec les versions de MATLAB
- Compatible avec toutes les versions
Plateformes compatibles
- Windows
- macOS
- Linux
| Version | Publié le | Notes de version | Action |
|---|---|---|---|
| 1.1.0.0 | Changed the help info at the top of the file and the Description for FileExchange. |
||
| 1.0.0.0 |
