Page tree

 

Support | BlogContact Us | 844.332.2821

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

D toc
Excerpt

Returns true if the rightmost set of characters of a column of values matches a pattern. The source value can be any data type, and the pattern can be a

D s item
itempattern
, regular expression, or a string.

  • The ENDSWITH function is ideal for matching based on patterns for any data type. If you need to match strings using a fixed number of characters, you should use the RIGHT  function instead. See RIGHT Function.
  • See STARTSWITH Function.

D s
snippetBasic

String literal example:

D code

derive value:ENDSWITH(tweets,'?') as:'hasQuestion'

Output: Writes true into the new hasQuestion column if last letter of the tweets column value is "?". 

Trifacta pattern example:

D code

derive value:ENDSWITH(tweets,`{hashtag}{1,9}`) as:'hasHashtag'

Output: Generates the hasHashtag column containing true if the tweets column ends with 1-9 hashtag values. Otherwise, the hasHashtag column is set to false.

Regular expression pattern example:

D code

set col:Status value:IF(ENDSWITH,myNum,/([01][0-9][0-9]|2[0-4][0-9]|25[0-5])/),'myNum - valid','myNum - error')

Output: Sets the value in the Status column to myNum - valid if the value of the myNum column ends with a value between 0-255. Otherwise, the Status column is set to myNum - error.

D s
snippetSyntax

D code

derive value:ENDSWITH(column_any,pattern)

ArgumentRequired?Data TypeDescription
column_anyYanyName of the column to be applied to the function
patternYstringPattern or literal expressed as a string describing the pattern to which to match.

d-s-lang-notes

column_any

Name of the column to be searched.

  • Multiple columns and wildcards are not supported.

D s
snippetusage

Required?Data TypeExample Value
YesColumn referencemyColumn

pattern

D s item
itempattern
, regular expression, or string literal to locate in the values in the specified column.

D s
snippetusage

Required?Data TypeExample Value
YesString`{zip}`

D s
snippetExamples

Example - STARTSWITH and ENDSWITH Functions

Include Page
EXAMPLE - STARTSWITH and ENDSWITH Functions
EXAMPLE - STARTSWITH and ENDSWITH Functions

D s also
labelstring