SearchReplace Class
(Automation::SearchReplace)The SearchReplace
operator can be used to transform string input to output using either simple search and replace or more complex POSIX regular expressions search and replace. More...
Header: | #include <SearchReplace.h> |
Inherits: | CDPOperator<std::string> |
Public Functions
~SearchReplace() override = default |
Reimplemented Public Functions
virtual unsigned int | Process() override |
- 18 public functions inherited from CDPOperator
- 17 public functions inherited from CDPOperatorBase
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Additional Inherited Members
- 1 public variable inherited from CDPOperatorBase
- 1 static public member inherited from CDPBaseObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
- 8 protected variables inherited from CDPOperator
- 5 protected variables inherited from CDPOperatorBase
- 11 protected variables inherited from CDPBaseObject
Detailed Description
The SearchReplace
operator can be used to transform string input to output using either simple search and replace or more complex POSIX regular expressions search and replace.
The SearchReplace operator has the following properties:
Property | Description |
---|---|
Regex | When set, then the POSIX regular expression search and replace is used, otherwise simple search for Search strings and replace them with Replace sting method is used. |
Search | Pattern to search for. When Regex is set, then POSIX regular expression search pattern with search groups to find from input. |
Replace | Text to replace found pattern with. When Regex is set, then references to the POSIX regular expression matchs groups like $1, $2 can be used here). |
Note: The input string will be forwarded to output unchanged when the Search pattern is not matching at all.
For example, the following Search and Replace patterns can be used to add a prefix and suffix to the input string (for example "some-text" becomes to "Prefix,some-text,suffix"):
Property | Description |
---|---|
Regex | 1 |
Search | (.+) |
Replace | Prefix,$1,suffix |
Or for example, the following Search and Replace patterns can be used to replace all dots in the input string to the hyphens in output (for example "some.text.string" becomes to "some-text-string").
Property | Description |
---|---|
Regex | 0 |
Search | . |
Replace | - |
Below is a table with the most useful special characters in POSIX {http://en.wikipedia.org/wiki/Regular_expression} {regular expression} patterns:
(...) | Specifies a block (regex group). Anything that is matched inside parenthesis can be references using $1 $2 etc in the Replace field. |
. | Matches any character |
\. | Matches . character (dot) |
\s | Matches any whitespace character (space, tab or newline) |
\S | Matches any non-whitespace character (any character except space, tab and newline) |
\d | Matches any digit character |
\D | Matches any non-digit character |
\w | Matches any alphanumeric character (letter, number or underscore) |
\W | Matches any non-letter character (so it is not a letter, number nor underscore) |
+ | Indicates one or more occurrences of the preceding elements. For example, S+ causes to match one or more sequential non-whitespace characters. |
* | Indicates zero or more occurrences of the preceding elements. For example, S* causes to match any number (or zero) sequential non-whitespace characters. |
You can learn more about regex expression possibilities, at:
Member Function Documentation
[default]
SearchReplace::~SearchReplace()
Destroys the instance of SearchReplace.
[override virtual]
unsigned int SearchReplace::Process()
Reimplemented from CDPOperatorBase::Process().
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.