0

Could you tell me how I would write a regular expression for the string below in ant? I have a property called typeSplitFirstPart. I want to insert a couple of values after the property typeSplitFirstPart which can either be Product_A or Product_PD or Product_CD (see below).

CSDT_FLAG_PRODUCT_FF_FWUIDS=Product_A:*;Product_PD:*;Product_CD:*

Currently I have this, but it is not working.

   <replaceregexp file="x" flags="s" match="([^\.]*)\$\{typeSplitFirstPart:\*?\}([^\.]*)" replace="$HELLOEVERYONE\2"/>
4

1 回答 1

1

这些是纯正则表达式模式,假设 * 是除分号 ( [^;])之外的任何字符

第一部分是强制性的,至少一个产品是强制性的,产品不能为空:

^([A-Z_]+)=(?:(Product_[A-Z]+):([^;]+);?)+

第一部分是强制性的,产品是可选的但不是空的:

^([A-Z_]+)=(?:(Product_[A-Z]+):([^;]+);?)*

第一部分是强制性的,产品是可选的,它们可以是空的:

^([A-Z_]+)=(?:(Product_[A-Z]+):([^;]*);?)*

请注意,以开头的组?:没有返回任何优化。

于 2013-01-15T12:16:50.863 回答