我需要匹配行中的单词。例如:
The blue bird is dancing.
Yellow card is drawn
The day is perfect rainy
blue bird is eating
这四行文本保存在名为
l2
的文件中。我想要匹配蓝色的鸟、黄色的卡片、日期,每次打印出匹配的单词后再打印该行。
y=regexp(l2,('^(?=.*blue bird)|(?=.*day)|(?=.*Yellow card)$'));
这是它的工作方式吗?我无法获得结果。
sprintf('[%s]',y,l2);