To replace text in Smereka one should login as editor, choose the base node to replace and click "Replace" button on the toolbar to the left of the inspector.
This button invokes the replacement text dialog. It should specify: attribute name, which need to replace, the text to find, the text to insert instead found, the "Domain" selector and the "Replace mode" selector.
"Domain" selector sets the scope of the command. This may be one of the following: the current node, crown (current node + all it child nodes), child nodes (only subordinate nodes without current), sibling nodes and sibling nodes with the crowns.
"Replace mode" selector can be set in one of the following: literal, extended, preg_replace.
Before the command execution search and replace texts are normalized, i.e. all lines breaks turned to Windows style – CR+LF. Since this style is Smereka internal style to store text, replacement of text with many lines becomes more predictable.
Please be aware that for language-dependent attributes "Replace text" command will make replacement in the current language version of attributes only.
Literal replace mode
With literal replace mode all characters of search and replace text assumed to be literals, that represent themselves. No replacement and substitution of them are made, all whitespace is interpreted as they are recorded. In this mode user has two options:
1. If the "Search text" is filled (not empty), then specified attribute is scanned and all occurrences of the search text replaced with replacement text (which can be empty, in this case, the matched fragments simply deleted).
2. If the "Search text" is empty, the specified attribute definitely replaced with replacement text. This option is very similar to the "Set attribute" command, with the difference that this command can set the multy-line text, and the "Set attribute" command – only the one-line text.
Extended replace mode
In extended mode search text interpreted literally, and the replacement text should contain magic symbols.
Add at the begin / end
To take opportunity to add text to the begin or end of the attribute, one must leave blank the search text. In the replacement text magic symbols [DdtSp] and [DdtKn] are markers of the texts to be inserted respectively before or after existing attribute value.
For example, let the replacement text is:
[DdtSp]The Pope [DdtKn] Mercedes.
(note the record in a one row and spaces), and a node set have next values of some attribute :
has a dog
has a car
has a boss
Then the result of this command to set values:
The Pope has a dog Mercedes.
The Pope has a car Mercedes.
The Pope has a boss Mercedes.
Replacement text may contain only one symbol, but if one set both, [DdtSp] must be first, and after them – [DdtKn].
Replace the head / tail
For this option search text should be given. Replacement text must contain magic symbols [GlvA] and / or [XvsT]. If the attribute contains a searched text, the text that comes before it is treated as head and the text that goes after it – as tail. The command replaces in replacement text the [GlvA] magic symbol with head, and [XvsT] magic symbol – with the tail.
For example, if a search text set to <hr> and the replacement text – to [GlvA], then from each attribute that contains a horizontal line tag will be deleted everything that comes after this tag (including the tag itself, i.e. the search text). If the replacement text is set to [GlvA] <hr>, head is attached to the specified text. Similarly, if the replacement text is set to [XvsT], the command will removed from the attribute all that goes before the search text (and the search text itself).
Replacement text, given as [XvsT] [GlvA], will reverse the head and tail of the text attribute, and so on.
Please consider that this mode is only used first occurrence of searched text in the value attribute.
Regular expressions replace mode
In preg_replace mode the next PHP functions carried out the processing:
preg_replace ([Text Search] [Text change], [Attribute Value])
Thus, the search text must be valid regular expression with syntax that matches PCRE (Perl-Compatible Regular Expressions), including characters, modifiers and restrictions. Accordingly, the replacement text may contain links to matched fragments, as explained in . Please consider that this regime is replacing all the fragments that match a given rule.
Previous section | Table of content | Next section