DB<41> $_="hello"; say pos,"($1)" while m/(o*$)/g; # pos doesn't change 5(o) 5() DB<42> p "hello" =~ s/x*$/O/gr; # empty match (no x) helloO