Counts the number of instances of a specified pattern in a column and writes that value into a newly generated column. Source column is unchanged. 

countpattern col: myCol on: 'honda'

Output: Generates a new column containing the number of instances of the string honda that appear in each row of the column, myCol

countpattern col:column_ref [ignoreCase:true|false] [after:start_point | from: start_point] [before:end_point | to:end_point] [on:'exact_match']

TokenRequired?Data TypeDescription
countpatternYtransformName of the transform
colYstringSource column name
ignoreCaseNbooleanIf true, matching is case-insensitive.

Matching parameters:

NOTE: At least one of the following parameters must be included to specify the pattern to count: after, before, from, on, to.

TokenRequired?Data TypeDescription
afterNstringString literal or pattern that precedes the pattern to match
beforeNstringString literal or pattern that appears after the pattern to match
fromNstringString literal or pattern that identifies the start of the pattern to match
onNstringString literal or pattern that identifies the pattern to match.
toNstringString literal or pattern that identifies the end of the pattern to match

col

Identifies the column to which to apply the transform. You can specify only one column.

countpattern col: MyCol on: 'MyString'

Output: Counts the number of instances of the value MyString in the MyCol column and writes this value to a new column. 

Required?Data Type
YesString (column name)

after

countpattern col: MyCol after: 'entry:'

Output: Counts 1 if there is anything that appears in the MyCol column value after the string entry:If the value entry: does not appear in the column, the output value is 0.

Required?Data Type
NoString (string literal or pattern)

before

countpattern col: MyCol before: '|'

Output:

Required?Data Type
NoString or pattern

from

countpattern col: MyCol from: 'go:'

Output: 

Required?Data Type
NoString or pattern

on

countpattern col: MyCol on: `###ERROR`

Tip: You can insert the Unicode equivalent character for this parameter value using a regular expression of the form /\uHHHH/. For example, /\u0013/ represents Unicode character 0013 (carriage return). For more information, see Supported Special Regular Expression Characters.

 

Required?Data Type
No

String (literal, regular expression, or     )

to

countpattern col:MyCol from:'note:' to: `/`

Output:

Required?Data Type
NoString or pattern

ignoreCase

countpattern col: MyCol on: 'My String' ignoreCase: true

Output: Counts the instances of the following values if they appear in the MyCol column: My Stringmy stringMy string, etc.

Required?Data Type
NoBoolean


Example - counting patterns in tweets