in reply to Replacing string with its length in Regex

You can execute code in the right-hand side of a substitution, by supplying the /e modifier.
s/(X+)/length $1/eg;

_____________________________________________________
Jeff japhy Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;