CONTAINSTR returns TRUE if PATTERN is found in any element of string array S.
Sometimes, I need to search strings that match multiple patterns.
The use of strfind (regexp) combing with for-loop (cellfun) makes the script look long and messy.
In newer version (R2016b), it is easy to do in a single line of code.
Just call the built-in function 'contains', that easily determine if pattern is in string.
So, I created this function for users with older version to search pattern in text.
This function follows the same behaviour as 'contains'.
No more for-loop is needed.
wen-feng Huang (2021). containstr (https://www.mathworks.com/matlabcentral/fileexchange/70334-containstr), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!