Perl,使用tr函数同时将大写转换为小写,反之亦然? [英] Perl, using tr function to convert uppercase to lowercase and vice-versa at the same time?
本文介绍了Perl,使用tr函数同时将大写转换为小写,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串
$string= 'AbCdEf';
并且我想使用 tr 函数将所有大写字母转换为小写字母,并将所有小写字母转换为大写字母......同时.我基本上只是想把它反转成.
and I want to use the tr function to convert all the uppercase letters to lower case and all the lower case to upper case.... at the same time. I basically just want to reverse it to become.
aBcDeF
我想出了这条线,但我不知道如何修改它来做我想做的事.有什么帮助吗?
I came up with this line, but I'm not sure how to modify it to do what I want. Any help please?
$string=~ tr/A-Z/a-z/;
谢谢!
推荐答案
$string =~ tr/A-Za-z/a-zA-Z/;
这篇关于Perl,使用tr函数同时将大写转换为小写,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文