Reputation: 2481
I have an ANT script which will have a property whose value could be one or more lines e.g. property
prop1=
A_12.1_REL_B121000_10_18_2011.1700
A_12.1_REL_B121001_10_25_2011.6059
A_12.1_REL_B121001_10_25_2011.2201
A_12.1_REL_B121001_10_25_2011.2014
Please see that all these lines end with a CRLF and end of file is also another CRLF. Now what I need to do is just select the last line using a regex. The number of lines could be less or more e.g
prop1=
A_12.1_REL_B121000_10_18_2011.1700
In the second case I need to select this single line . I have searched older posts, but could not find anything specific. Any pointers ?
Upvotes: 4
Views: 3032
Reputation: 26930
If you are using ant-contrib :
<loadfile srcFile="input.prop" property="test"/>
<propertyregex property="result"
input="${test}"
regexp="(.*$)"
select="\1"
/>
<echo message="Result is : ${result}"/>
This will always print the last line of your input properties file :
[echo] Result is : A_12.1_REL_B121001_10_25_2011.2014
Upvotes: 1