GS Example: Using White Space in a Regular Expression

This example shows how to use white space characters in a regular expression in find and replace strings.

Suppose your repository contains a map with structured documents with multiple attribute values separated by a single space. You know the last value specified for the attribute, and you want to append an additional attribute value to that value. The Global Substitution tool supports the use of spaces in regular expressions in rules to accomplish this goal.
  1. Select a DITA map that references the topics you want to change.
  2. Right-click the map and select Search > Global Substitution
    The Global Substitution dialog appears.
  3. Click New two times to add rows to the table.
    The table now contains three rows.
  4. In the first row of the Substitute Parameters table, create a rule to include all topics in the cabinet, folder, and subfolders:
    1. In the Type field, select Preprocess.
    2. In the Find field, select getMapTopics.
  5. In the second row of the Substitute Parameters table, create a rule to process all elements:
    1. In the Type field, select Preprocess from the drop-down list.
    2. In the Find field, type getElements.
    3. In the Find field, change the text inside the parentheses to ("//*").
  6. In the third row of the Substitute Parameters table, create a rule using a regular expression to find the specified attribute value and replace it with that value appended by a new value.
    1. In the Type field, select Set Attribute from the drop-down list.
    2. In the Find field, enter a space, type the attribute value, and enter the $ character.
      For example, value1$.
      The $ character indicates the end of value or line.
    3. In the Replace with field, enter a space, retype the attribute value, enter another space, and type the additional attribute value.
      For example, value1 value2.
    4. Select the Case-Sensitive check box.
    5. Select the RegEx check box.
  7. Select the Check In check box.
  8. Type a Version Note.
    For example, GS: 3/22/16 Added value2 attribute value to value1.
  9. Review the dialog. It should look like this:


    Note: Red lines in the image indicate a single space.
  10. Click OK.
A batch job is executed to perform the changes. When the job completes, you receive an email notification.

Topics that are changed during this job are updated and have the Version Note you entered.