Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Described regex attributes

...

Each dynamic variable assignment can be filtered using a Java regular expression. This is done by the nested regex element.

Attributes:

  • regexp
    The Java regular expression to be used for selecting from the variable value or for replacing certain parts of the variable value. For more information see the Java Platform SE 6 API and other documents describing the according regular expression syntax more in detail.
  • select (one of both, select or replace must be given)
    Selection expression according to regexp, used to select certain groups from the expression defined in regexp and possibly combine them with several text around.
  • replace (one of both, select or replace must be given)
    Replacement expression according to regexp, used to replace the regular expression defined in regexp and possibly combine them with several text around.
  • defaultValue (optional)
    The default value to be used if the expression defined in regexp does not match the enclosing variable value at all.
  • casesensitive (optional, defaults to "true")
    Whether the regular expression matching should consider the case of alphabetic letters or not for matching.
  • global (optional, defaults to "false")
    Whether the replacement operation should be performed on the entire variable value, rather than just the first occurance. This has effect only on using together with replace.

Example:

Code Block
langxml
titleFiltering dynamic variable assignments using regular expressions
<dynamicvariables>

    <variable name="previous.version" jarfile="${INSTALL_PATH}/${INSTALL_SUBPATH}/libs/config.jar"
              entry="release.properties" type="options"
              key="release.version"
              checkonce="false" ignorefailure="true" condition="upgradecheck">
      <regex regexp="([0-9]+(\.[0-9]+){2})" select="\1" defaultvalue="none"/>
    </variable>

    <variable name="RegExTest.Select.Windows" checkonce="true"
              regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
              regvalue="Path">
      <regex regexp="([^;]*)(.*)"
             select="\1"
             defaultValue="(unmatched)"
             casesensitive="false"/>
    </variable>

    <variable name="RegExTest.ReplaceFirst.Windows" checkonce="true"
              regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
              regvalue="Path">
      <regex regexp="([^;]*)"
             replace="+++ \1 +++"
             defaultValue="(unmatched)"
             casesensitive="false"
             global="false"/>
    </variable>

    <variable name="RegExTest.ReplaceAll.Windows" checkonce="true"
              regkey="HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
              regvalue="Path">
      <regex regexp="([^;]*)"
             replace="+++ \1 +++"
             defaultValue="(unmatched)"
             casesensitive="false"
             global="true"/>
    </variable>

</dynamicvariables>