如何提取文本并设置为变量批处理代码CMD [英] How to extract text and set as variable Batch Code CMD

查看:289
本文介绍了如何提取文本并设置为变量批处理代码CMD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据这个文本文件提取用户在线:

https://minecraft-statistic.net/en/server/167.114.43.185_25565/json/



I将其保存为文本文件。里面有一些东西:

lockquote

 players_list:[Raskhol] [Lukaka ],map:... etc 


提取_ list:,map之间的所有文本,并将其设置为变量。所以,当我调用变量%Playerlist%,它会说:


<$ p
$






$ $ $ $类似于@ geisterfurz007的答案,这一个假设你是在players_list的第一个实例之后:在map的第一个实例之前



@Echo Off
Set / P var =< some.json
Set var =%var:,map=&:%
Set var =%var:*players_list:=%
Echo =%var%
超时-1


I would like to extract what users are online based on this text file:
https://minecraft-statistic.net/en/server/167.114.43.185_25565/json/

I will save it as a text file. Inside that there is something:

"players_list":["Raskhol"]["Lukaka"],"map":...etc

I would like to extract all the text between "_list": and ,"map" and set it as a variable. So that when I call the variable %Playerlist%, it would say:

["Raskhol"]["Lukaka"]

解决方案

similar to @geisterfurz007's answer, this one assumes the you are after the first instance of "players_list": before the first instance of ,"map"

@Echo Off
Set/P var=<some.json
Set var=%var:,"map"=&:%
Set var=%var:*"players_list":=%
Echo=%var%
Timeout -1

这篇关于如何提取文本并设置为变量批处理代码CMD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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