Advanced Search and Replace
Advanced Search and Replace action tasks are used to locate and replace strings of data within the job file and to replace them with other strings of data. Contrary to Search and Replace action tasks, they allow the use of regular expressions.
Using regular expressions, it is possible to search for patterns rather than specific strings. For instance, a pattern can be specified to find all valid email addresses or phone numbers within the data stream.
Input
Any text-based file can be used in this task, even formats that are not directly compatible with PlanetPress. As long as the text is visible in a text-based editor (such as Notepad), it is readable and supported by this task.
Processing
The appropriate changes are made to the data file (replacing text).
Output
The modified data file is output from this task. Metadata is not modified in any way if it is present.
Advanced Search and Replace action task properties are as follows:
General tab
- Search mode group: Select your chosen search mode within this group.
- Search line by line: Select if you want each line in the data stream to be searched separately. When this option is selected, PlanetPress Workflow considers each line as an individual data stream (lines are separated by Line Feed characters). It minimizes memory requirements but may also limit hits, since lines are considered separately. Note that it is not possible to use search expressions that specify multiple data lines when this option is selected.
- Search whole file: Select if you want the entire data stream to be searched as if it were a single string of text. When this option is selected, PlanetPress Workflow loads the entire file in memory. It offers more flexibility, since search expressions may span across multiple lines and may result in more successful hits. Note that since this option uses more memory, it may affect performance.
- String to search: Enter your search string or regular expression in this variable property box. To enter multiple strings or expressions, press Enter after each one (note that only one string can be entered in the Replace with box).
- Treat as regular expression: Select to specify that the string or strings entered above are to be interpreted as regular expressions rather than ordinary text strings. This option disables all position options as well as the Whole words only option.
- Search options group
- Case sensitive: Select to force the plugin to match the character casing of the search string above with the characters found in the file. If this option is selected, “DAY” and “Day” will not be considered as matching the search string “day”.
- Whole word only: Select force the plugin to search only for strings that match the search string from beginning to end (cannot be used with regular expressions). If this option is selected, “DAY” and “DAYS” will not be considered as matching strings.
- Position options group: Specify the location where the string must be found using this group. Note that this whole group is disabled when the Treat as regular expression option is selected.
- Anywhere on the line: Select to indicate that the search string can be anywhere on the line.
- At the beginning of a line: Select to indicate that the search string must be the first string on the line.
- At the end of a line: Select to indicate that the search string must be the last string on the line.
- At column: Select to indicate that the search string must be in a specific column. Specify the column number (the value must be greater then 0) in the box below.
- Between specific words: Select to indicate that the search string must be between specific words. Specify these words in the Words before and Words after boxes below.
- Occurrence related: Select to indicate that the search string must be found a specific number of times before a string replacement is performed. If the Search line by line option is selected in the Search mode group, the search counter is reset for every line. If the Search whole file option is selected in the Search mode group, the search counter is not reset before the end of the file. Select one of the occurrence options (described below) in the list box below and enter a value in the variable property box besides it.
- At occurrence: The replacement will take place only when the specified number of occurrences has been reached. Specifying 2 occurrences, for instance, means that only the second occurrence will be replaced.
- At every specified occurrence: The replacement will take place every time the specified number of occurrences is reached. Specifying 2 occurrences, for instance, means that the second, the fourth and the sixth (and so on) occurrence will be replaced.
- All after occurrence: All occurrences of the search string will be replaced once the specified number of occurrences has been reached. Specifying 2 occurrences, for instance, means that all occurrences after the second one will be replaced.
- All before occurrence: All occurrences of the search string will be replaced until the specified number of occurrences has been reached. Specifying 5 occurrences, for instance, means that the four first occurrences will be replaced.
- Replace with: Enter the string that must be used as the replacement sting when a match is found.
On Error Tab
By default, any action task, branch, splitter or condition that generates an error will simply be ignored, and the task just under it (not within a branch) will be given control of the job file without any modification. Any initial input task that generates an error will stop the process from running as a whole, and output tasks will not generate output. The On Error tab can be used to overwrite the default behaviors.
- Send to Process: Check this option to send the job file to an error management process.
- Error Process drop-down: Enabled only when the Send to Process option is checked. Lists any process of which the initial input task is the Input Error Bin task.
- Action Group: This group is disabled in the initial input tasks and defaults to Stop Process. In all other tasks where the On Error tab is present, the following options are available:
- Ignore: The task is ignored as if it did not exist, and the job file is passed on to the next task in the process.
- Stop Branch: If the task is in a branch of the process, the branch is stopped and the job file is returned to the process after the branch. The branch will not produce any output.
- Stop Process: The process is stopped and no more processing is done. No further output is produced.
- Log Message: Check this option to enable logging a custom error message in the PlanetPress Suite Workflow Tools' log file.
- Message: Enabled only when the Log Message option is checked. Enter a message that will be logged in the PlanetPress Suite Workflow Tools' log file. You can use any variables available in PlanetPress Workflow to customize the message.
- Store the message in variable: Select in which jobinfo, local or global variable you want to store the message content.
- ID: Enter an error ID. This ID will be visible in the Windows Event Viewer. However, the ID is not visible in the PlanetPress Suite Workflow Tools' log file.
- Store the ID in variable: Select in which jobinfo, local or global variable you want to store the error ID.
- Reset to defaults: Resets all options in this tab to their default values.
If storing the message or ID, if they are store in a jobinfo they will be available in any error handling process where errors are being forwarded. In all cases, if your process continues after the error, the contents of the variables selected in this window will be available for the rest of your process, or whenever they are overwritten.
Common Errors
Though some error messages are specific to a task in particular, others may apply to any and all tasks because they are related more to the system than to PlanetPress itself. Some examples would be W3813, W3830, W3991, W4005. These correspond to issues such as not having any space to write files, permission errors on folders or files, etc.
Comments Tab
The Comments tab, added in PlanetPress Suite 7.5, is common to all tasks. It contains a single text area (Task comments) that lets you write comments about the task. These comments are saved when the dialog is closed with the OK button, and are displayed in The Task Comments Pane.