# OPs original case.
echo 'there there are are multiple lexical errors in this line line' | sed 's/\([a-z]\+[ ,\n]\+\)\1/\1/g'
# Now add a space after 'line'
echo 'there there are are multiple lexical errors in this line line ' | sed 's/\([a-z]\+[ ,\n]\+\)\1/\1/g'
# To fix the original case..move the word separator outside the capture group
echo 'there there are are multiple lexical errors in this line line' | sed -e 's/\([a-z]\+\)[ ,\n]\1/\1/g'
# THAT ALONE DOES NOT WORK!!!
# Add a word boundary requirement.
echo 'there there are are multiple lexical errors in this line line' | sed -e 's/\b\([a-z]\+\)[ ,\n]\1/\1/g'
# THAT WORKS!!!
IyBPUHMgb3JpZ2luYWwgY2FzZS4KZWNobyAndGhlcmUgdGhlcmUgYXJlIGFyZSBtdWx0aXBsZSBsZXhpY2FsIGVycm9ycyBpbiB0aGlzIGxpbmUgbGluZScgfCBzZWQgICdzL1woW2Etel1cK1sgLFxuXVwrXClcMS9cMS9nJwoKIyBOb3cgYWRkIGEgc3BhY2UgYWZ0ZXIgJ2xpbmUnCmVjaG8gJ3RoZXJlIHRoZXJlIGFyZSBhcmUgbXVsdGlwbGUgbGV4aWNhbCBlcnJvcnMgaW4gdGhpcyBsaW5lIGxpbmUgJyB8IHNlZCAgJ3MvXChbYS16XVwrWyAsXG5dXCtcKVwxL1wxL2cnCgojIFRvIGZpeCB0aGUgb3JpZ2luYWwgY2FzZS4ubW92ZSB0aGUgd29yZCBzZXBhcmF0b3Igb3V0c2lkZSB0aGUgY2FwdHVyZSBncm91cAplY2hvICd0aGVyZSB0aGVyZSBhcmUgYXJlIG11bHRpcGxlIGxleGljYWwgZXJyb3JzIGluIHRoaXMgbGluZSBsaW5lJyB8IHNlZCAtZSAncy9cKFthLXpdXCtcKVsgLFxuXVwxL1wxL2cnCiMgVEhBVCBBTE9ORSBET0VTIE5PVCBXT1JLISEhCgojIEFkZCBhIHdvcmQgYm91bmRhcnkgcmVxdWlyZW1lbnQuCmVjaG8gJ3RoZXJlIHRoZXJlIGFyZSBhcmUgbXVsdGlwbGUgbGV4aWNhbCBlcnJvcnMgaW4gdGhpcyBsaW5lIGxpbmUnIHwgc2VkIC1lICdzL1xiXChbYS16XVwrXClbICxcbl1cMS9cMS9nJwojIFRIQVQgV09SS1MhISEK