我试图在ant文件中使用正则表达式(使用replaceregexp标签)来替换java类中的特定字符串(这不是常量)时,我一直在努力,例如:
将V2_0_0替换为V1_0_0
在:
public void doSomething() {
return "xxxxxxxV1_0_0.yyyyyyyy"
}
当然V1_0_0总会改变 并且.yyyyyyyy会改变,但xxxxxxx将是相同的
这是我越接近: (?< = xxxxxxx)。*或(?< = xxxxxxx)。*
但这就是我得到的:
public void doSomething() {
return "xxxxxxxV2_0_0;
}
xxxxxxx或yyyyyyyy可以是java类名中允许的任何字符
答案 0 :(得分:1)
试试这样:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="navcontainer">
<ul>
<li>
<label class=" container-check">Australia
<input class="filter-check country" type="checkbox" name="country" value="Australia">
</label>
</li>
<li>
<label class=" container-check">United Kingdom
<input class="filter-check country" type="checkbox" name="country" value="United Kingdom">
</label>
</li>
<li>
<label class=" container-check">USA
<input class="filter-check country" type="checkbox" name="country" value="USA">
</label>
</li>
<li>
<label class=" container-check">New Zealand
<input class="filter-check country" type="checkbox" name="country" value="New Zealand">
</label>
</li>
</ul>
</div>
<div id="navcontainer1">
<ul>
<li>
<label class=" container-check">Vineyard / Viticulture
<input class="filter-check category" type="checkbox" name="country" value="Vineyard / Viticulture">
</label>
</li><li>
<label class=" container-check">Winemaking / Lab / Production
<input class="filter-check category" type="checkbox" name="country" value="Winemaking / Lab / Production">
</label>
</li><li>
<label class=" container-check">Harvest / Vintage
<input class="filter-check category" type="checkbox" name="country" value="Harvest / Vintage">
</label>
</li>
<li>
<label class=" container-check">Cellar Door
<input class="filter-check category" type="checkbox" name="country" value="Cellar Door">
</label>
</li>
<li>
<label class=" container-check">General Management
<input class="filter-check category" type="checkbox" name="country" value="General Management">
</label>
</li>
<li>
<label class=" container-check">Sales / Marketing / Retail / Distributor
<input class="filter-check category" type="checkbox" name="country" value="Sales / Marketing / Retail / Distributor">
</label>
</li>
</ul>
</div>
我使用(?:xxxxxxx)V[0-9]+_[0-9]+_[0-9]+(?:\.[a-z]+)?
使yyyyyy
部分可选。
也许你需要一个不同于?
的角色类,可能是a-z
或[a-zA-Z]
。
[a-zA-Z0-9_]