REGEX-Escape for: /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\...

Your Input:
Result, the escaped string:
\/\^\\s\*\(\(#\[a\-f\\d\]\{6\}\)\|\(#\[a\-f\\d\]\{3\}\)\|rgba\?\\\(\\s\*\(\[\\d\\\.\]\+%\?\\s\*,\\s\*\[\\d\\\.\]\+%\?\\s\*,\\s\*\[\\d\\\.\]\+%\?\(\?\:\\s\*,\\s\*\[\\d\\\.\]\+%\?\)\?\)\\s\*\\\)\|hsba\?\\\(\\s\*\(\[\\d\\\.\]\+\(\?\:deg\|\\xb0\|%\)\?\\s\*,\\s\*\[\\d\\\.\]\+%\?\\s\*,\\s\*\[\\d\\\.\]\+\(\?\:%\?\\s\*,\\s\*\[\\d\\\.\]\+\)\?\)%\?\\s\*\\\)\|hsla\?\\\(\\s\*\(\[\\d\\\.\]\+\(\?\:deg\|\\xb0\|%\)\?\\s\*,\\s\*\[\\d\\\.\]\+%\?\\s\*,\\s\*\[\\d\\\.\]\+\(\?\:%\?\\s\*,\\s\*\[\\d\\\.\]\+\)\?\)%\?\\s\*\\\)\)\\s\*\$\/i,

What must the escaping look like for:
/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,

The excaped text for use in a regex is:
\/\^\\s\*\(\(#\[a\-f\\d\]\{6\}\)\|\(#\[a\-f\\d\]\{3\}\)\|rgba\?\\\(\\s\*\(\[\\d\\\.\]\+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