If the short phrase occurs in a longer phrase, like "buffer not" also occurs in "buffer not available" and "memory for pxa buffer not available", I WANT TO KEEP THE "memory for pxa buffer not available".

The output should be a text file containing all the longest error messages.
Like this: