Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r100
Excerpt

This example demonstrates functions that can be used to compare two sets of strings.

Functions:

D generate list excerpts
pagesSTRINGGREATERTHAN Function,STRINGGREATERTHANEQUAL Function,STRINGLESSTHAN Function,STRINGLESSTHANEQUAL Function,EXACT Function

Source:

The following table contains some example strings to be compared. 

rowIdstringAstringB
1aa
2aA
3ab
4a1
5a;
6;1
7a a
8aaa
9abcx

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
RawWrangletrue
p03Value'greaterThan'
Typestep
WrangleTextderive type:single value: STRINGGREATERTHAN(stringA,stringB) as: 'greaterThan'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueSTRINGGREATERTHAN(stringA,stringB)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'greaterThanEqual'
Typestep
WrangleTextderive type:single value: STRINGGREATERTHANEQUAL(stringA,stringB) as: 'greaterThanEqual'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueSTRINGGREATERTHANEQUAL(stringA,stringB)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'lessThan'
Typestep
WrangleTextderive type:single value: STRINGLESSTHAN(stringA,stringB) as: 'lessThan'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueSTRINGLESSTHAN(stringA,stringB)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'lessThanEqual'
Typestep
WrangleTextderive type:single value: STRINGLESSTHANEQUAL(stringA,stringB) as: 'lessThanEqual'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueSTRINGLESSTHANEQUAL(stringA,stringB)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'exactEqual'
Typestep
WrangleTextderive type:single value: EXACT(stringA,stringB) as: 'exactEqual'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueEXACT(stringA,stringB)
p03NameNew column name
SearchTermNew formula

 

Results:

In the following table, the Notes column has been added manually.

rowIdstringAstringBlessThanEquallessThangreaterThanEqualgreaterThanexactEqualNotes
1aatruefalsetruefalsetrueEvaluation of differences between STRINGLESSTHAN and STRINGGREATERTHAN and greater than versions.
2aAtruetruefalsefalsefalseComparisons are case-sensitive. Uppercase letters are greater than lowercase letters.
3abtruetruefalsefalsefalse
Letters later in the alphabet (b) are greater than earlier letters (a).
4a1falsefalse
true true false
Letters (a) are greater than digits (1).
5a;falsefalsetruetruefalseLetters (a) are greater than non-alphanumerics (;).
6;1truetruefalsefalsefalse

Digits (1) are greater than non-alphanumerics (;). Therefore, the following characters are listed in order of evaluation:

Code Block
Aa1;
7a afalsefalsetruetruefalseLetters (and any non-breaking character) are greater than space values.
8aaatruetruefalsefalsefalseThe second string is greater, since it contains one additional string at the end.
9abcxtruetruefalsefalsefalseThe second string is greater, since its first letter is greater than the first letter of the first string.

D s also
labelexample_string_comparison_functions