The regex for the return key is \r
. \R
would presumably work as well.
The problem with this is that \
does not just escape all characters - for some characters it makes them mean something.
So while you're probably safe with the using \-
in place of -
, it's not guaranteed. Since -
is just a regular character like any other character, it is not impossible that a future change or some extension would make \-
mean something else in the same way that r
is a regular character and \r
means something else.
So while I understand the simplicity of just escaping everything, it has its own risks, especially with potential future compatibility.
The ICU documentation is explicit on which characters must be quoted, but not clear on what can safely be quoted.
/
quotes the following character. Characters outside of sets that must be quoted to be treated as literals are *
?
+
[
(
)
{
}
^
$
|
\
.
. Characters [inside sets] that must be quoted to be treated as literals are [
]
\
and depending on the context are -
&
.
As an aside, I often use the more literal nature of inside sets to avoid excess use of backslash which otherwise can lead to Leaning Toothpick Syndrome by using regex such as [*]
or [$]
.
Anyway, as long as you're comfortable with that possible future compatibility, it should be safe enough to just quote everything non-alphanumeric.