Почему g
делает две замены в перле и яве?
user@localhost:$ echo "test////////" | perl -pe "s/\/*$/d/"
testd
user@localhost:$ echo "test////////" | perl -pe "s/\/*$/d/g"
testdd
duser@localhost:$echo "test////////" | sed -e "s/\/*$/d/"
testd
user@localhost:$ echo "test////////" | sed -e "s/\/*$/d/g"
testd
user@localhost:$ echo "test////////" | sed -re "s/\/*$/d/g"
testd
user@localhost:$ echo "test////////" | sed -re "s/\/*$/d/"
testd
testdd
, replaceFirst testd
. Я ожидал одну замену.