strspan(X;Y;C;D)
Returns the position of the first (or last) character in a given string that is found (or not found) in another string.
Syntax
strspan(X;Y;C;D)
bstrspan(X;Y;C;D)
Input
Argument | Type | Description |
---|---|---|
X |
text | The string on which to apply the function A scalar value or the name of a column |
Y |
text | Y is the string containing a set of characters to find in
X .A scalar value or the name of a column |
C |
integer | Specifies whether the function searches X for characters that
are either present or not present in Y If
If
|
D |
integer | Specifies in which direction the search is performed If
If
|
Return Value
Returns an integer value corresponding to the first (or last) character in the string
X
that is found (or not found) in the string Y
.
The function searches X
for any character that is either present in
Y
(if C
=1) or not present in
Y
(if C
=0).
The search proceeds in a forward direction (i.e., the first matching character in
X
is returned) if D
=1. The search
is reversed, returning the last matching character in X
, if
D
=-1.
X
is N/A, then the result is:- 0 if
D
=1 - N/A if
D
=-1
Y
is N/A, then the result is:- 1 if
C
=0 andD
=1 - 0 if
C
=1 andD
=1 - the length of
X
ifC
=0 andD
=-1 - N/A if
C
=1 andD
=-1
If C
<0, the result is N/A.
Sample Usage
value |
string2 |
present |
direction |
strspan(value;string2;present;direction) |
---|---|---|---|---|
'apple' | 'aeiou' | 1 | 1 | 1 |
'apple' | 'aeiou' | 1 | -1 | 5 |
'apple' | 'aeiou' | 0 | 1 | 2 |
'apple' | 'aeiou' | 0 | -1 | 4 |
'' | 'aeiou' | 0 | 1 | 0 |
'apple' | '' | 0 | -1 | 5 |
Additional Information
strspan
is 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
bstrspan
can be used with non-Unicode strings (e.g., binary or legacy encodings).