MATLAB: Matching two texts

matching

Hi,
I have two texts . is it possible to extract the text where the two arrays match.For example: A='First Boston Corp Lehman Brothers ' B='Lehman Brothers Merill Lynch'; How can I get the match "Lehman Brothers"

Best Answer

The simple brute force method:
A='Lehman Brothers Merill Lynch';
B='First Boston Corp Lehman Brothers';
for n = 1:numel(B);
for k = 1:n
if ~isempty(strfind(A,B(k + (0:numel(B)-n))))
Bmatch = B(k + (0:numel(B)-n))
return
end
end
end