# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/^([a-zA-Z0-9].+?)(\s+)((?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29))(\s+)((0?9|1[0-9]|2[01]):00~(1[0-9]|2[0-2]):00)(\s+)([A-D])(\sC)//;t' <<< "U001 2020-01-01 9:00~22:00 A C"
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