Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的第一个问题在这里。
我有一串数字,比如55111233
55111233
如您所见,5 连续两次,1 三次 2 一次和 3 两次。
我想把它换成52132132
52132132
一般来说number1<count>number2<count>...numbern<count>
number1<count>number2<count>...numbern<count>
请指导我。
$digits = "55111233"; $digits =~ s/((\d)\2*)/$2 . length($1)/ge; print $digits;
你可以做:
$str =~s/(\d)(\1*)/$1.(length($2)+1)/eg;