How to split string without for loop in batch file

前端 未结 6 932
暗喜
暗喜 2020-12-06 05:33

I want to split a string in two parts, without using any for loop.

For example, I have the string in a variable:

str=45:abc

I want

6条回答
  •  一生所求
    2020-12-06 06:09

    Yes, I know this is a very old topic, but I just discovered it and I can't resist the temptation of post my solution:

    @echo off
    setlocal
    
    set "str=45:abc"
    set "var1=%str::=" & set "var2=%"
    echo var1="%var1%"  var2="%var2%"
    

    You may read full details of this method here.

提交回复
热议问题