我需要删除部分字符串,以便我可以使用该消息。尝试了许多不同的方法失败了。提前致谢
想象我有这样一条消息:
SET MESSAGE="The key sequence '1' in 'http://www.myschema.com/dummy:dummy_PK' Keyref fails to refer to some key."
我需要删除它:
in 'http://www.myschema.com/dummy:dummy_PK' Keyref
得到这样的东西:
"The key sequence '1' fails to refer to some key."
答案 0 :(得分:0)
试试这个:
@echo off
setlocal
SET "MESSAGE=The key sequence '1' in 'http://www.myschema.com/dummy:dummy_PK' Keyref fails to refer to some key."
SET "sFind=in 'http://www.myschema.com/dummy:dummy_PK' Keyref "
call set New=%%Message:%sFind%=%%
echo %New%
答案 1 :(得分:0)
假设in
和Keyref
只出现一次,|
永不出现,那么:
@echo off
setlocal enableDelayedExpansion
set message="The key sequence '1' in 'http://www.myschema.com/dummy:dummy_PK' Keyref fails to refer to some key."
set "message=!message: in =|!"
set "message=!message: Keyref =|!"
for /f "delims=| tokens=1,3" %%A in ("!message!") do set "message=%%A %%B"
set message