How to split string using batch file?

前端 未结 2 1602
有刺的猬
有刺的猬 2021-01-21 15:05
  • How to split string using batch script?

SET java_path=\"C:\\Program Files\\Java\\jdk1.6.0_31\"

above is my string, i wa

相关标签:
2条回答
  • 2021-01-21 15:40

    try this:

    @ECHO OFF &SETLOCAL
    SET "java_path=C:\Program Files\Java\jdk1.6.0_31"
    SET "this=%java_path:~3%"
    SET "this=%this:*\=%"
    CALL SET "this=%%java_path:%this%=%%"
    SET "this=%this:~0,-1%"
    ECHO %this%
    
    0 讨论(0)
  • 2021-01-21 15:43

    You may split strings by character position:

    ECHO %java_path:~1,16%

    or by splitting at specific characters:

    FOR /F "DELIMS=\ TOKENS=1,2" %i IN (%java_path%) DO ECHO %i\%j

    0 讨论(0)
提交回复
热议问题