progtips

substring(text,pos,length)

最終更新:

progtips

- view
メンバー限定 登録/ログイン

ソースコード

@echo off
setlocal
set pos=7
set length=4
set text=Hello, World!
call set res=%%text:~%pos%,%length%%% 
echo substring("%text%",%pos%,%length%): %res%

実行結果

substring("Hello, World!",7,4): Worl

解説

途中にCALLをはさむことによって、「%text:~7,4%」となった文字列を、さらに再評価している。Perl/JavaScriptでのevalに相当する。
記事メニュー
目安箱バナー