ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Heath, Graham" <Graham.He...@fujitsu-siemens.com>
Subject regexp teaser!
Date Thu, 26 Jun 2008 07:34:20 GMT
Hi guys,

I am using the following targets to read the Windows registry.
  <target name="ADSVersion" depends="rawADSVersion" if="exists.ADSVersion" unless="ADSVersion">
    <pathconvert property="ADSVersion">
      <path path="${rawADSVersion}"/>
      <mapper type="regexp" from=".*REG_SZ[     ]*(.*)\b" to="\1"/>
    </pathconvert>
          <echo level="info" message="ADSVersion=${ADSVersion}"/>
  </target>
  <target name="rawADSVersion" depends="REGExe,ADSKeyString,VersionValueString" unless="rawADSVersion">
    <exec executable="${REGExe}" failonerror="false" resultproperty="rcodeADS" outputproperty="rawADSVersion">
      <arg value="QUERY"/>
      <arg value="&quot;${ADSKeyString}&quot;"/>
      <arg value="/v"/>
      <arg value="${VersionValueString}"/>
    </exec>
    <condition property="exists.ADSVersion">
      <not>
        <isfailure code="${rcodeADS}"></isfailure>
      </not>
    </condition>
  </target>
These work fine for most registry keys that I require. My problem is that when I try to read
the InstallDir registry key the regexp does not return 'D:\temp\ADS' as expected but 'D'.
It seems as though The ':' acts as a line terminator. I have tried
      <mapper type="regexp" from=".*REG_SZ[     ]*(.*)$" to="\1"/>
which worked when the supplied path was a property (pre-) defined in build.xml but failed
when the identical(?) string was read from the registry.

Could some regexp guru refactor my expression so that it works, or an ant guru point me at
a better way of parsing the rawADSVersion

Thanks,
Graham



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message