In Powershell (5.1 or 7), I run:
PS R:\> "abcdef" -replace '.*','x'
xx
PS R:\> "abcdef" -replace '.+','x'
x
PS R:\> "abcdef" -replace '^.*','x'
x
PS R:\> "abcdef" -replace '^.+','x'
x
PS R:\>
PS R:\> "abcdef" -replace '^','x'
xabcdef
PS R:\>
As you can see, in the first run I got xx
but was expecting a single x
.
Tried with sed in bash (executables from gitdir/usr/bin; msys I think), and got what I expected.
2021-05-01 01:34:27 /r :
$ echo "abcdef" | sed -E s/.*/x/g
x
2021-05-01 01:35:03 /r :
$ echo "abcdef" | sed -E s/.+/x/g
x
2021-05-01 01:35:08 /r :
$ echo "abcdef" | sed -E s/^.*/x/g
x
2021-05-01 01:35:17 /r :
$ echo "abcdef" | sed -E s/^.+/x/g
x
2021-05-01 01:35:20 /r :
$ echo "abcdef" | sed -E s/^/x/g
xabcdef
2021-05-01 01:35:25 /r :
$
I have tried the documentation and cant figure out how to understand what is happening.