[英]ANT script to read a value from a file
I am having following input file, I need an ant script command to get the Test value when its having value (1 of 1) in the line: 我有以下输入文件,当它在行中具有值(1的1)时,我需要一个ant脚本命令来获取Test值:
(123) "Test 1" (0 of 1) (123)“测试1”(1之0)
(456) "Test 2" (1 of 1) (456)“测试2”(1之1)
(789) "Test 3" (0 of 1) (789)“测试3”(1之0)
Expected output: Test 2 预期输出:测试2
I tried using regexp, but its not working. 我尝试使用regexp,但无法正常工作。
Thanks in advance. 提前致谢。
Ant is not a scripting language. Ant不是脚本语言。 It's designed to process collections of files, so is poorly optimized for performing analysis on individual files.
它被设计为处理文件集合,因此在对单个文件进行分析时没有进行优化。
I would suggest you use an external program to scan the file, for example: 我建议您使用外部程序来扫描文件,例如:
<project name="demo" default="build">
<target name="build">
<exec executable="awk">
<arg line="'/\(1 of 1\)/ {print $2,$3}' input.txt"/>
</exec>
</target>
</project>
Or embed a scripting language like Javascript or Groovy within your ANT build. 或在ANT构建中嵌入诸如Javascript或Groovy之类的脚本语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.