language: Bash (bash 4.0.35)
date: 368 days 20 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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!!!
 
  • upload with new input
  • result: Success     time: 0.03s    memory: 5312 kB     returned value: 0

    there are multiple lexical errors in this line line
    there are multiple lexical errors in this line 
    there are multiplexical errors in this line
    there are multiple lexical errors in this line