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

D toc

Excerpt

Returns true if the leftmost 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 lang
itempattern
, regular expression, or a string.

  • The STARTSWITH 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 LEFT  function instead. See LEFT Function.
  • See ENDSWITH Function.

D s lang vs sql

D s
snippetBasic

String literal example:

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:startswith(FullName,'Mr.')

startswith(FullName,'Mr.')

Output: Returns true if the first three letters of the FullName column value are "Mr.". 

D s lang
itempattern
 example:

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:startswith(CustId,`{alpha-numeric}{6}`) as:'validateCustId'

startswith(CustId,`{alpha-numeric}{6}`)

Output: Returns true if the CustId column begins with a six-digit alpha-numeric sequence. Otherwise, the value is set to false.

Regular expression example:

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextset col:Status value:if(startswith(phone,/^(\+0?1\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$/),'phone - ok','phone - error')

if(startswith(phone,/^(\+0?1\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$/),'phone - ok','phone - error')

Output: Returns phone - ok if the value of the phone column begins with a value that matches a 10-digit U.S. phone number. Otherwise, the output value is set to phone - error.

D s
snippetSyntax

D lang syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:startswith(column_any,pattern)

startswith(column_any,pattern[,ignore_case])


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.
ignore_caseNstringWhen true, matching is case-insensitive. Default is false.

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 lang
itempattern
, regular expression, or string literal to locate in the values in the specified column.

D s
snippetusage

Required?Data TypeExample Value
YesString`{zip}`

ignore_case

When true, matches are case-insensitive. Default is false

Info

NOTE: This argument is not required. By default, matches are case-sensitive.

D s
snippetusage
 

Required?Data TypeExample Value
NoString value'false'

D s
snippetExamples

Example - STARTSWITH and ENDSWITH Functions

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

D s also
labelstring