[Solved] sed/regex to change only few of multiple matching characters


with sed

based on position

$ echo abc-def-ghi-2017-10-31 | sed 's/-/./4g'
abc-def-ghi-2017.10.31

based on surrounding chars

$ echo abc-def-ghi-2017-10-31 | sed -r 's/([0-9])-([0-9])/\1.\2/g'
abc-def-ghi-2017.10.31

based on the position from the end of string

$ echo abc-def-ghi-2017-10-31 | rev | sed 's/-/:/g; s/:/-/3g' | rev
abc-def-ghi-2017:10:31

2

solved sed/regex to change only few of multiple matching characters