# token-replace-first

<token-replace-first> replaces in the result of the enclosed tokens the first substring that matches the regular expression specified by regex with the string specified by replace-with.

See http://java.sun.com/j2se/1.4/docs/api/java/util/regex/Pattern.html and http://java.sun.com/j2se/1.4/docs/api/java/util/regex/Matcher.html#replaceAll(java.lang.String)

Note that pattern option CASE_INSENSITIVE, DOTALL, and UNICODE_CASE are used but can be reversed using the appropriate embedded escapes.

### Example

>     <token-replace-first regex="^(.*), (.*)$" replace-with="$2 $1">
>       <token-attr name="Full Name"/>
>     </token-replace-first>

## 1. Allowed Content

> token-added-entitlement
>   the value(s) of an entitlement granted in the current operation
> token-association
>   the association value from the current operation
> token-attr
>   the value(s) of an attribute in the current operation or current object in the source datastore
> token-base64-decode
>   decode base64 data into a string
> token-base64-encode
>   encode a string into base64 data
> token-char
>   a unicode character
> token-class-name
>   the object class name from the current operation
> token-convert-time
>   convert a date/time from one format to another
> token-dest-attr
>   the value(s) of an attribute of current object in the destination datastore
> token-dest-dn
>   a value derived from the destination DN from the current operation
> token-dest-name
>   the unqualified RDN derived from destination DN from the current operation
> token-document
>   read an XML document
> token-entitlement
>   the value(s) of a granted entitlement of the current object
> token-escape-for-dest-dn
>   convert a string for use in a destination DN
> token-escape-for-src-dn
>   convert a string for use in a source DN
> token-generate-password
>   generate a random password
> token-global-variable
>   the value of a global variable
> token-join
>   join a node-set into a string
> token-local-variable
>   the value of a local variable
> token-lower-case
>   convert a string to lower case
> token-named-password
>   the value of the named password
> token-map
>   map a string through a mapping table
> token-op-attr
>   the value(s) of an attribute in the current operation
> token-op-property
>   the value of an operation property
> token-operation
>   the name of the current operation
> token-parse-dn
>   parse and/or convert a DN
> token-password
>   the value of the password in current operation
> token-query
>   query the source or destination datastore
> token-removed-attr
>   the value(s) of an attribute removed in the current operation
> token-removed-entitlement
>   the value(s) of an entitlement revoked in the current operation
> token-replace-all
>   replace all instances of a substring within a string
> token-replace-first
>   replace a single instance of a substring within a string
> token-resolve
>   resolve a DN to an association key or an association key to a DN.
> token-split
>   split a string into a node-set
> token-src-attr
>   the value(s) of an attribute of current object in the source datastore
> token-src-dn
>   a value derived from the source DN from the current operation
> token-src-name
>   the unqualified RDN derived from source DN from the current operation
> token-substring
>   substring of a string
> token-text
>   constant text
> token-time
>   the current date/time
> token-unique-name
>   a generated unique name
> token-unmatched-src-dn
>   a DN relative to the one matched by if-src-dn
> token-upper-case
>   convert a string to upper case
> token-xml-parse
>   parse XML
> token-xml-serialize
>   serialize XML
> token-xpath
>   the result of an XPATH expression

## 2. Attributes

> Attribute | Value(s) | Default Value
> --- | --- | ---
> notrace | true | false true if this element should not be traced during execution of policy | false
> regex | CDATA regular expression that matches the substring to replace supports variable expansion | #REQUIRED
> replace-with | CDATA the replacement string supports variable expansion | #REQUIRED

## 3. Content Rule

> ( token-added-entitlement | token-association | token-attr | token-base64-decode | token-base64-encode | token-char | token-class-name | token-convert-time | token-dest-attr | token-dest-dn | token-dest-name | token-document | token-entitlement | token-escape-for-dest-dn | token-escape-for-src-dn | token-generate-password | token-global-variable | token-join | token-local-variable | token-lower-case | token-named-password | token-map | token-op-attr | token-op-property | token-operation | token-parse-dn | token-password | token-query | token-removed-attr | token-removed-entitlement | token-replace-all | token-replace-first | token-resolve | token-split | token-src-attr | token-src-dn | token-src-name | token-substring | token-text | token-time | token-unique-name | token-unmatched-src-dn | token-upper-case | token-xml-parse | token-xml-serialize | token-xpath ) +

## 4. Parent Elements

> arg-association
>   association argument
> arg-component
>   component argument
> arg-dn
>   DN argument
> arg-node-set
>   node set argument
> arg-password
>   password argument
> arg-string
>   string argument
> arg-value
>   value argument
> token-base64-decode
>   decode base64 data into a string
> token-base64-encode
>   encode a string into base64 data
> token-convert-time
>   convert a date/time from one format to another
> token-escape-for-dest-dn
>   convert a string for use in a destination DN
> token-escape-for-src-dn
>   convert a string for use in a source DN
> token-join
>   join a node-set into a string
> token-lower-case
>   convert a string to lower case
> token-map
>   map a string through a mapping table
> token-parse-dn
>   parse and/or convert a DN
> token-replace-all
>   replace all instances of a substring within a string
> token-replace-first
>   replace a single instance of a substring within a string
> token-split
>   split a string into a node-set
> token-substring
>   substring of a string
> token-upper-case
>   convert a string to upper case
> token-xml-parse
>   parse XML
> token-xml-serialize
>   serialize XML

Top Elements || All Elements || Tree