stredit(X;P;N;Y)
Returns a given string, with a specified number of characters starting at a certain position replaced by a given substring.
Syntax
stredit(X;P;N;Y)
bstredit(X;P;N;Y)
Input
| Argument | Type | Description |
|---|---|---|
X |
text | The string on which to apply the function A scalar value or the name of a column |
P |
integer | An index corresponding to a particular position in XThe
index A negative position counts back from the end of the string (i.e.,
If
|
N |
integer | The number of characters to replace in
X
If
|
Y |
text | Y is the substring to be replaced in X.A scalar value or the name of a column |
Return Value
Returns the text value corresponding to the string X with the
N characters beginning at position P replaced with the
string Y.
If X is N/A, the result is Y. If Y is
N/A, the effect is to delete N characters from X (i.e.,
replace them with the empty string).
X as
necessary.Sample Usage
value |
position |
number |
newstring |
stredit(value;position;number;newstring) |
|---|---|---|---|---|
| 'testing' | 2 | 1 | 'oa' | 'toasting' |
| 'testing' | -3 | -1 | 'er | 'tester' |
| 'testing' | 1 | 2 | '' | 'sting' |
| 'testing' | -3 | -1 | '' | 'test' |
| 'testing' | 1 | 0 | 'con' | 'contesting' |
Additional Information
streditis Unicode (UTF-8) compliant and will work with Unicode or plain ASCII text fields.- If passed a string argument that is not legal Unicode, it will by default signal an error (configurable as a user preference).
- A corresponding function
bstreditcan be used with non-Unicode strings (e.g., binary or legacy encodings).
