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 , 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.
String literal example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:endswith(tweets,'?') as:'hasQuestion' |
---|
|
endswith(tweets,'?') |
Output: Returns true
if last letter of the tweets
column value is "?".
example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:endswith(tweets,`{hashtag}{1,9}`) as:'hasHashtag' |
---|
|
endswith(tweets,`{hashtag}{1,9}`) |
Output: Returns true
if the tweets
column ends with 1-9 hashtag values. Otherwise, the returned value is false
.
Regular expression example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | set col:Status value:if(endswith,myNum,/([01][0-9][0-9]|2[0-4][0-9]|25[0-5])/),'myNum - valid','myNum - error') |
---|
|
if(endswith,myNum,/([01][0-9][0-9]|2[0-4][0-9]|25[0-5])/),'myNum - valid','myNum - error') |
Output: Returns myNum - valid
if the value of the myNum
column ends with a value between 0-255. Otherwise, myNum - error
is returned.
D lang syntax |
---|
RawWrangle | true |
---|
Type | syntax |
---|
showNote | true |
---|
WrangleText | derive type:single value:endswith(column_any,pattern) |
---|
|
endswith(column_any,pattern[,ignore_case]) |
Argument | Required? | Data Type | Description |
---|
column_any | Y | any | Name of the column to be applied to the function |
pattern | Y | string | Pattern or literal expressed as a string describing the pattern to which to match. |
ignore_case | N | string | When true , matching is case-insensitive. Default is false . |
column_any
Name of the column to be searched.
- Multiple columns and wildcards are not supported.
Required? | Data Type | Example Value |
---|
Yes | Column reference | myColumn |
pattern
, regular expression, or string literal to locate in the values in the specified column.
Required? | Data Type | Example Value |
---|
Yes | String | `{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. |
Required? | Data Type | Example Value |
---|
No | String value | 'false' |
Example - STARTSWITH and ENDSWITH Functions
Include Page |
---|
| EXAMPLE - STARTSWITH and ENDSWITH Functions |
---|
| EXAMPLE - STARTSWITH and ENDSWITH Functions |
---|
|