I guess it's best to start with an example:
> echo "[20-20:10]Something" | sed -r -e 's/^\[[0-9\:\-]+(.*)$/\1/'
]Something
> echo "[20-20:10]Something" | sed -r -e 's/^\[[0-9\-\:]+(.*)$/\1/'
-20:10]Something
The only difference is that I swapped :
and -
characters in character class of regex. So: does the order of characters matter in sed's regex's character classes? I doesn't seem to matter on different regex systems, like https://regex101.com/.
I cannot find anything about this behaviour on Google, but I would like to know more, because I want to be sure to know what my scripts do.
]
or^
or if it's part of a character class name, e.g.[:space:]
. – Ed Morton Feb 25 '20 at 22:19