Reputation: 44230
this is my string com.element.subelement
I want to use propertyregex
to replace all .
with /
, and use that output as a directory path.
It seemed like propertyregex would be the tool for this, but maybe I am using its regexp
property incorrectly.
How would I use regex to find the .
only, I don't want to assume that the string is 3 alphabet portions separated by periods. also perhaps propertyregex is not the tool for the job
here is one that works where I assume that a package name only have 2 periods
<!-- set package name to folder directory -->
<propertyregex
property="current.target.dir"
input="com.element.subelement"
regexp="(.+?)\.(.+?)\.(.+?)"
replace="\1/\2/\3"
casesensitive="false" />
<echo>${current.target.dir}</echo>
Upvotes: 2
Views: 9743
Reputation: 33341
Simply replacing \.
with /
should accomplish what you're looking for, if I understand. However, this will only replace the first instance on a line by default, so you have to add the property global="true"
:
<propertyregex
property="current.target.dir"
input="com.element.subelement"
regexp="\."
replace="/"
global="true" />
Upvotes: 3