替换批处理脚本中的字符串字符 [英] Replace character of string in batch script

查看:167
本文介绍了替换批处理脚本中的字符串字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从字符串中替换字符*,如下所示:
*10.*31.**2.*65

I need to replace character * from a string which is some what like this:
*10.*31.**2.*65

我想使用批处理脚本从此字符串中删除所有*.

I want to remove all the * from this string using batch script.

推荐答案

@ECHO OFF
SETLOCAL
SET mystring=*10.31.*2.*65
:deaster
FOR /f "tokens=1* delims=*" %%i IN ("%mystring%") DO (
   SET mystring=%%j
   IF DEFINED mystring (
      SET mystring=%%i%%j
      GOTO deaster
   ) ELSE (
      SET mystring=%%i
   )
)
ECHO result=%mystring%=

这篇关于替换批处理脚本中的字符串字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆