# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/(((?:[+\-\\/*]6+|6+[+\-\\/*]|([^6]|\b)6{1,2}(?3)|(?3)6{6,}(?3)|[0-57-9]6+|6+[0-57-9])(*SKIP)(*F))|6)/六/gm;t' <<< "66
老铁666这类的, 6666
三到五个六66666
5666有其他数字不替换
6665
566665
666666
66
+66
666-
"
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html