ReplaceSubstringFirst
Replaces the first occurrence of a substring in a text string with a new substring.
Syntax
bool ReplaceSubstringFirst (string TextToSearch , string Substring , string Replacement , string CaseSensitive)
Parameters
- TextToSearch
- Type: String
- Substring
- Type: String
- Replacement
- Type: String
- CaseSensitive
- Type: String
Smart parameters are supported.
Returns
Always True.
Level
All levels.
Details
This action searches the text of the field or variable that is referenced in the TextToSearch parameter. The first occurrence of the specified Substring is replaced with the Replacement parameter and the location that TextToSearch refers to is updated.
If the smart parameter specified in TextToSearch resolves to a field's "text" value, this action maintains the existing confidence values of the characters that are not replaced. The replacement characters are set to a high confidence value. If TextToSearch resolves to a DCO variable, then the confidence value does not apply.
The Replacement parameter is not required to be the same length as the substring.
Example 1
ReplaceSubstringFirst(@F, "TOO", "Three", "True")
Because the specification is @F, the action runs on a field to update the captured text in the field. If the field's text value is "This Too is TOO Much Text Too", then the final value is "This Too is Three Much Text Too" because the search is case-sensitive. If the confidence of the field is "55555555555555555555555555555" after updating the text value, the field confidence becomes "5555555555559999955555555555555".
Example 2
rrSet("This Too is TOO Much Text Too", "@X.MyVariable")
ReplaceSubstringFirst(@X.MyVariable, "TOO", "Three", "false")
The example first sets a DCO variable on the current DCO object to the value "This Too is TOO Much Text Too". This is performed as an illustration. Typically the variable would have been set earlier. The action ReplaceSubstringFirst updates the variable MyVariable to "This Three is TOO Much Text Too".
Example 3
ReplaceSubstringFirst(@P\Field1, ".", ",", "False)
This action runs on a page object that has an existing child field called "Field1". The action updates the text value of Field1. If the text value of the field has a value of "1.234.56", then the final value of the field will be "1,234.56". If the confidence of the field was "72387279" after updating the text value, the field confidence becomes "79387279".
See also
Refer to the top level help for more information regarding smart parameters.