Excerpt |
---|
This example demonstrates functions that can be used to compare two sets of strings. |
Functions:
D generate list excerpts |
---|
pages | STRINGGREATERTHAN Function,STRINGGREATERTHANEQUAL Function,STRINGLESSTHAN Function,STRINGLESSTHANEQUAL Function,EXACT Function |
---|
|
Source:
The following table contains some example strings to be compared.
rowId | stringA | stringB |
---|
1 | a | a |
2 | a | A |
3 | a | b |
4 | a | 1 |
5 | a | ; |
6 | ; | 1 |
7 | a | a |
8 | a | aa |
9 | abc | x |
Note that in row #6, stringB
begins with a space character.
Transformation:
For each set of strings, the following functions are applied to generate a new column containing the results of the comparison.
D trans |
---|
RawWrangle | true |
---|
p03Value | 'greaterThan' |
---|
Type | step |
---|
WrangleText | derive type:single value: STRINGGREATERTHAN(stringA,stringB) as: 'greaterThan' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | STRINGGREATERTHAN(stringA,stringB) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'greaterThanEqual' |
---|
Type | step |
---|
WrangleText | derive type:single value: STRINGGREATERTHANEQUAL(stringA,stringB) as: 'greaterThanEqual' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | STRINGGREATERTHANEQUAL(stringA,stringB) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'lessThan' |
---|
Type | step |
---|
WrangleText | derive type:single value: STRINGLESSTHAN(stringA,stringB) as: 'lessThan' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | STRINGLESSTHAN(stringA,stringB) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'lessThanEqual' |
---|
Type | step |
---|
WrangleText | derive type:single value: STRINGLESSTHANEQUAL(stringA,stringB) as: 'lessThanEqual' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | STRINGLESSTHANEQUAL(stringA,stringB) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'exactEqual' |
---|
Type | step |
---|
WrangleText | derive type:single value: EXACT(stringA,stringB) as: 'exactEqual' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | EXACT(stringA,stringB) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Results:
In the following table, the Notes
column has been added manually.
rowId | stringA | stringB | lessThanEqual | lessThan | greaterThanEqual | greaterThan | exactEqual | Notes |
---|
1 | a | a | true | false | true | false | true | Evaluation of differences between STRINGLESSTHAN and STRINGGREATERTHAN and greater than versions. |
2 | a | A | true | true | false | false | false | Comparisons are case-sensitive. Uppercase letters are greater than lowercase letters. |
3 | a | b | true | true | false | false | false
| Letters later in the alphabet (b) are greater than earlier letters (a). |
4 | a | 1 | false | false
| true | true | false
| Letters (a) are greater than digits (1). |
5 | a | ; | false | false | true | true | false | Letters (a) are greater than non-alphanumerics (;). |
6 | ; | 1 | true | true | false | false | false | Digits (1) are greater than non-alphanumerics (;). Therefore, the following characters are listed in order of evaluation: |
7 | a | a | false | false | true | true | false | Letters (and any non-breaking character) are greater than space values. |
8 | a | aa | true | true | false | false | false | The second string is greater, since it contains one additional string at the end. |
9 | abc | x | true | true | false | false | false | The second string is greater, since its first letter is greater than the first letter of the first string. |
D s also |
---|
label | example_string_comparison_functions |
---|
|