Regexp exact word match
问题 I need to match words from lines. For example: The blue bird is dancing. Yellow card is drawn The day is perfect rainy blue bird is eating The four lines are in a text file l2 . I want to match the blue bird, yellow card, day and every time a line is printed that matched word is printed before the line. y=regexp(l2,('^(?=.*blue bird)|(?=.*day)|(?=.*Yellow card)$')); Is this how it works? I can't get the result. sprintf('[%s]',y,l2); 回答1: MATLAB's regex engine doesn't use \b as word boundary