Get last character of a string from a variable

前端 未结 2 1777
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 16:25

I am having issues with a problem accomplished very easily in most languages but I can\'t seem to figure it out in batch. I want to extract the last character of a string.

2条回答
  •  独厮守ぢ
    2020-12-28 16:51

    Batch does not use C style logic, so you really have to think differently for much of it.

    That said, String -right appears to be what you want: http://www.dostips.com/DtTipsStringManipulation.php#Snippets.RightString

    %str:~-1%
    

    That will get you the last character.

提交回复
热议问题