Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml eclipse搜索替换正则表达式迭代_Xml_Regex_Expression - Fatal编程技术网

Xml eclipse搜索替换正则表达式迭代

Xml eclipse搜索替换正则表达式迭代,xml,regex,expression,Xml,Regex,Expression,我想换一个 step=“1”step=“2”step=“5”step=“33” 有以下几点 step=“1”step=“2”step=“3”step=“4” 我希望替换的数字将其迭代更正为1 到目前为止,我发现: step=“\d” 这很好用。 如果您正在使用ant并且在项目中包含了ant contrib的话,我可以使用什么替换?p>如果您正在使用ant。 您可以使用任务增加var的值 假设${STEP\u STRING}=STEP=“1”STEP=“2”STEP=“5”STEP=“33” 生成

我想换一个

step=“1”step=“2”step=“5”step=“33”

有以下几点

step=“1”step=“2”step=“3”step=“4”

我希望替换的数字将其迭代更正为1

到目前为止,我发现:

step=“\d”

这很好用。
如果您正在使用
ant
并且在项目中包含了
ant contrib
的话,我可以使用什么替换?

p>如果您正在使用
ant

您可以使用
任务增加
var
的值

假设
${STEP\u STRING}
=
STEP=“1”STEP=“2”STEP=“5”STEP=“33”

生成
${NEW_STRING}
=
step=“1”step=“2”step=“3”step=“4”


${NEW_STRING}

我认为这将生成所需的字符串,尽管我还没有测试它,但它将构建一个新字符串,而不是替换以前的字符串(您正在寻找)。在挑选第n次出现的
=“\d”
时,替换变得复杂。
我想你需要一个自定义的
来完成这项任务,我将在这段时间内尝试编写它。

不幸的是,我认为这是不可能的,除非你找到一个与数字匹配的“回调”并将其递增。
<var name="ctr" value="1"/>
<var name="ctr_str" value="step"/>
<var name="NEW_STRING" value=""/>

<for list="${STEP_STRING}" delimiter="${ctr_str}" param="str">
   <sequential>          
      <condition property="true">
          <matches string="@{str}" pattern="=&quot;\d&quot;"/>
      </condition>
      <if><isset property="true"/>
          <then>
             <propertyregex property="xx" input="@{str}" regexp="(=&quot;)\d(&quot;)" replace="\1${ctr}\2" override="true"/>
             <var name="NEW_STRING" value="${NEW_STRING} ${ctr_str}${xx}"/>
             <math result="ctr" operand1="${ctr}" operand2="1" operation="+" datatype="int" />
          </then>
      </if>
   </sequential>
</for>
<echo>${NEW_STRING}</echo>