[victor@localhost ~]$ echo ${USER} victor [victor@localhost ~]$ echo ${USER:1} ictor [victor@localhost ~]$ echo ${USER:5:1} r [victor@localhost ~]$ echo ${USER:(-1)} r [victor@localhost ~]$ echo ${USER:(-2)} or [victor@localhost ~]$ echo ${USER:(-5)} ictor |
PS C:\> "victor" victor PS C:\> "victor".SubString(1); ictor PS C:\> "victor".SubString(5,1); r |
PS C:\> [string]::join('', ('victor')[-5..-1]) ictor PS C:\> [string]::join('', ('victor')[-2..-1]) or PS C:\> [string]::join('', ('victor')[-1..-1]) r |
复制代码
- PS C:\Users\admin> "powershellabc1234"[-1..-5] -join ""
- 4321c
- PS C:\Users\admin>
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |