1、dos下拼接字符串
[plain] view plaincopy
在CODE上查看代码片 [图片上传失败...(image-6f17ac-1516931943095)]<embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&width=16&height=16" wmode="transparent" style="box-sizing: border-box;">
- @echo off
- set a=aaaaa
- set b=bbbbb
- set c=%a%%b%
- echo %c%
- pause
以上代码将a和b的值拼接后赋给了变量c,运行结果:
image2、dos下截取字符串
[plain] view plaincopy
在CODE上查看代码片 [图片上传失败...(image-2bf3f6-1516931943095)]<embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&width=16&height=16" wmode="transparent" style="box-sizing: border-box;">
- @echo off
- set a=how are you!
- echo %a:~0,5%
- pause
以上代码截取了字符串a,从第0个字符到第5个字符,运行结果:
image3、字符串截取的另外一种方式
[plain] view plaincopy
在CODE上查看代码片 [图片上传失败...(image-c4ee87-1516931943094)]<embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_3" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&width=16&height=16" wmode="transparent" style="box-sizing: border-box;">
- @echo off
- set a=how are you!
- echo %a:~1,-3%
- pause
以上代码截取了字符串a,从第1个字符到倒数第3个字符,运行结果:
image4、dos截取完整字符串
[plain] view plaincopy
在CODE上查看代码片 [图片上传失败...(image-877215-1516931943094)]<embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_4" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&width=16&height=16" wmode="transparent" style="box-sizing: border-box;">
- @echo off
- set a=how are you!
- echo %a:~0%
- pause
以上代码截取了字符串a,从第0个字符到末尾的字符,运行结果:
image5、dos拼接截取字符串并用
[plain] view plaincopy
在CODE上查看代码片 [图片上传失败...(image-8bf9c5-1516931943094)]<embed id="ZeroClipboardMovie_5" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_5" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=5&width=16&height=16" wmode="transparent" style="box-sizing: border-box;">
- @echo off
- set a=my a
- set b=bookb
- set c=%a:0,3%%b:0,-1%
- echo %c%
- pause
运行结果:
image
网友评论