Reputation: 4501
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"/>
Upvotes: 0
Views: 114
Reputation: 1095
These are pure regex pattern assuming * is any character but semicolon ([^;]
)
First part is mandatory, at least one product is mandatory, and product can't be empty:
^([A-Z_]+)=(?:(Product_[A-Z]+):([^;]+);?)+
First part is mandatory, products are optional but not empty:
^([A-Z_]+)=(?:(Product_[A-Z]+):([^;]+);?)*
First part is mandatory, products are optional and they can be empty:
^([A-Z_]+)=(?:(Product_[A-Z]+):([^;]*);?)*
Just note that the group starting with ?:
is not returning anything for optimization.
Upvotes: 1