谢谢大家。我终于想出了答案。
使用以下正则表达式,
([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)
1
我们可以分别得到 groups和2
中的前 3 个字符串标记4
。但是该组2
带有一个前置;
,可以通过应用\;(.*)
和提取来进一步删除 group 1
。
property name="inputString" value="russia;uae;germany;africa;"
propertyregex property="string1" input="${inputString}" regexp="([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)" select="\1"
propertyregex property="string2" input="${inputString}" regexp="([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)" select="\2"
propertyregex property="string3" input="${string2}" regexp="\;(.*)" select="\1"
propertyregex property="string4" input="${inputString}" regexp="([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)" select="\4"
这为您提供了 string1、string3 和 string4 中所需的前三个标记
string1 = russia
string3 = uae
string4 = germany