Using NAnt, I'd like to check that my property matches the following pattern: [0-9a-zA-Z_]
.
I have tried this so far:
<condition property="check-my-prop">
<matches pattern="[1-9a-zA-Z_]" string="${MyProp}"/>
</condition>
<fail message="my-prop must match pattern [1-9a-zA-Z_]"
unless="check-my-prop" />
NAnt throws an error: Invalid element <condition>. Unknown task or datatype.
Code is adapted from Ant, not NAnt.
How can I achieve the same goal?
<property name="CheckMyProp" value="" />
<regex pattern="^(?'CheckMyProp'[1-9a-zA-Z_]+)$" input="${MyProp}" failonerror="false"/>
<if test="${string::get-length(CheckMyProp) == 0}">
<fail>MyProp must match pattern [1-9a-zA-Z_]</fail>
</if>