I\'m having trouble getting sed to recognize both hyphen and underscore in its pattern string.
Does anyone know why
[a-z|A-Z|0-9|\\-|_]
As mentioned, you don't need anything to separate your ranges in a bracket expression. All that will do is adding |
to the characters matched by the expression.
Then, to add a hyphen, you can put it as the first or last character in the expression:
[a-zA-Z0-9_-]
And finally, ranges like a-z
don't necessarily mean abcd...xyz
, depending on your locale. You could use a POSIX character class instead:
[[:alnum:]_-]
Where [:alnum:]
corresponds to all alphanumeric characters of your locale. In the C
locale, it corresponds to 0-9A-Za-z
.