0
variable=data
我该如何提取data
?我需要以某种方式设置variable=
。正在运行xidel file.txt -e "variable="
会给出错误err:XPST0003: Unexpected query end
并删除=
不会产生任何结果。如何使用xidel与自定义分隔符从文件中提取数据?
variable=data
我该如何提取data
?我需要以某种方式设置variable=
。正在运行xidel file.txt -e "variable="
会给出错误err:XPST0003: Unexpected query end
并删除=
不会产生任何结果。如何使用xidel与自定义分隔符从文件中提取数据?
实际上,xidel是用xquery/xpath/templates/jsonic等语言从xml/html/json等结构化数据中提取数据的,并不是专门为基于文本的提取而设计的。但是,您可以使用$ raw和正则表达式函数(如extract()和replace()来玩弄变量)。
因此,举例来说,如果你有类似内容的file.txt的:
var1=one
var2=two
var3=three
,你可以做到以下几点:
xidel -s file.txt -e "output:=extract($raw,'var2=(.*)',1)"
,其结果是:
output := two
现在,假设你在windows上,你可以使用for循环和--output-format cmd将它导出到一个环境变量中,如th e以下链接: https://stackoverflow.com/a/38599599/3910330
'for/F“标记= 2 delims ==”%L in(“variable = data”)设置“VALUE =%L”',然后'echo%VALUE%'显示数据... – aschipfl