美文网首页
dos拼接字符串以及截取字符串

dos拼接字符串以及截取字符串

作者: 04282aba96e3 | 来源:发表于2018-01-26 09:59 被阅读253次

    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;">

    1. @echo off
    2. set a=aaaaa
    3. set b=bbbbb
    4. set c=%a%%b%
    5. echo %c%
    6. pause

    以上代码将a和b的值拼接后赋给了变量c,运行结果:

    image

    2、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;">

    1. @echo off
    2. set a=how are you!
    3. echo %a:~0,5%
    4. pause

    以上代码截取了字符串a,从第0个字符到第5个字符,运行结果:

    image

    3、字符串截取的另外一种方式

    [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;">

    1. @echo off
    2. set a=how are you!
    3. echo %a:~1,-3%
    4. pause

    以上代码截取了字符串a,从第1个字符到倒数第3个字符,运行结果:

    image

    4、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;">

    1. @echo off
    2. set a=how are you!
    3. echo %a:~0%
    4. pause

    以上代码截取了字符串a,从第0个字符到末尾的字符,运行结果:

    image

    5、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;">

    1. @echo off
    2. set a=my a
    3. set b=bookb
    4. set c=%a:0,3%%b:0,-1%
    5. echo %c%
    6. pause

    运行结果:

    image

    相关文章

      网友评论

          本文标题:dos拼接字符串以及截取字符串

          本文链接:https://www.haomeiwen.com/subject/jrsiaxtx.html