A slightly more elegant way than Luis Mendo's solution is to use regexprep
that does exactly what you want
>> result = regexprep( 'Alligator in water', 'ins*', '' ); % replace with an empty string
result =
Alligator water
If you have several stop words you can simply add them to the pattern (in this example I consider 'in'
and 'near'
as stop words):
>> result = regexprep( 'Alligator in water near land', {'ins*','nears*'}, '' )
result =
Alligator water land
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…