gpt4 book ai didi

java - Ant 分词器 : Selecting an individual Token

转载 作者:行者123 更新时间:2023-11-29 06:22:39 24 4
gpt4 key购买 nike

我有以下 Ant 任务:

<loadfile property="proj.version" srcfile="build.py">
<filterchain>
<striplinecomments>
<comment value="#"/>
</striplinecomments>
<linecontains>
<contains value="Version" />
</linecontains>
</filterchain>
</loadfile>
<echo message="${proj.version}" />

输出是

 [echo] config ["Version"]          = "v1.0.10-r4.2"

然后我如何使用分词器只获取 v1.0.10-r4.2,相当于

| cut -d'"' -f4

最佳答案

你可以使用 containsregex filterchain 中的元素为 tokenfilter .

这应该过滤任何包含 "Version" 的行,并作为内容返回唯一捕获的组:'vx.y.zz....'

<支持> <包含正则表达式 pattern="^.?\"版本\".\"(v[^\"]+?)\"." 替换=“\1”/>不起作用。
可能是 可以工作(对 parameter 属性使用单引号,允许在参数值内使用非转义双引号)

实际上是 OP John Oxley提供双引号 (\") 替换为 " 的工作解决方案:

<containsregex
pattern="^.*?&quot;Version&quot;.*&quot;(v[^&quot;]+?)&quot;.*"
replace="\1" />

关于java - Ant 分词器 : Selecting an individual Token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2385455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com