Created
April 28, 2016 15:32
-
-
Save sco1/df3f59b62914047b09026658df574b99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Generate some dummy data | |
mystrs = {'hi hello this is robin'; ... | |
'we are the knights who say ni'; ... | |
'this is a string'; ... | |
'knight rider'; ... | |
'boogie nights'; ... | |
'boogie knights'; ... | |
}; | |
querystr = 'knight'; | |
% Generate regular expression...expression based on query string | |
expression = sprintf('\\<(%s)\\>', querystr); | |
% Return where matches start in each cell | |
matchstart = regexp(mystrs, expression, 'start'); | |
% Find first non-empty cell, signifying a match | |
firstcellwithquerystring = find(~cellfun(@isempty, matchstart), 1, 'first'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment