grep
grep — find matches of a string in a vector of strings
Calling sequence
row=grep(str1,str2)
[row,which]=grep(str1,str2)
Parameters
str1 | : a vector of strings. |
str2 | : a character string or character string vector . The string(s) to search in str1 |
row | : vector of indices: row where a match has been found or an empty matrix if no match found. |
which | : vector of indices: index of str2 string found or an empty matrix if no match found. |
Description
Foreach entry of str1, grep searches if at least a string in
str2 matches a substring. str1 entries index where at least a match has been
found are returned in the row argument. while optionnal
which argument gives the index of first string of str2 found.
Examples
txt=['find matches of a string in a vector of strings'
'search position of a character string in an other string'
'Compare Strings'];
grep(txt,'strings')
grep(txt,['strings' 'Strings'])
[r,w]=grep(txt,['strings' 'Strings'])
See also
strindex