Hive Automate supports a variety of string formulas. Formulas in Hive Automate are whitelisted Ruby methods, and therefore not all Ruby methods are supported. Syntax and functionality for these formulas are generally unchanged. Take note that most formulas will return an error and stop the job if it tries to operate on nulls (expressed as 'nil' in Ruby), except for .present?, .presence and .blank?.

You can refer to the syntax and sample uses of these commands by clicking the links below:


blank?

This formula checks the input string and returns true if it is an empty string or if it is null.

Syntax

Input.blank?

  • Input - An input datapill. It can be a string, number, date, or datetime datatype.

Sample usage

Formula

Result

"Any Value".blank?

false

123.blank?

false

0.blank?

false

"".blank?

true

How it works

If the input is null or an empty string, the formula will return true. For any other data, it returns false.


is_not_true?

Evaluates a boolean value and returns true if the evaluated value is not true.

Syntax

Input.is_not_true?

  • Input - An input boolean, an integer (1 or 0), or an accepted string value.

Sample usage

Formula

Result

true.is_not_true?

false

false.is_not_true?

true

0.is_not_true?

true

nil.is_not_true?

true

How it works

Takes in an input and evaluates if it is true or false.


is_true?

Evaluates a boolean value and returns true if the evaluated value is true.

Syntax

Input.is_true?

  • Input - An input boolean, an integer (1 or 0), or an accepted string value.

Sample usage

Formula

Result

true.is_true?

true

false.is_true?

false

0.is_true?

false

nil.is_true?

false

How it works

Takes in an input and evaluates if it is true or false.


present?

This formula will check the input and if there is a value present, it will return true. If the input is nil, boolean false, an empty string, or an empty list, the formula will return false.

Syntax

Input.present?

  • Input - An input datapill. It can be a string, number, date, or list datatype.

Sample usage

Formula

Result

"Any Value".present?

true

123.present?

true

0.present?

true

"2017-04-02T12:30:00.000000-07:00".present?

true

nil.present?

false

"".present?

false

[].present?

false

How it works

If the input is null, an empty string or an empty list, the formula will return false. For any other data, it returns true.


presence

Returns the data if it exists, returns nil if it does not.

Syntax

Input.presence

  • Input - An input datapill. It can be a string, number, date, or datetime datatype.

Sample usage

Formula

Result

nil.presence

nil

"".presence

nil

"Any Value".presence

"Any Value"

45.0.presence

45.0

0.presence

0

How it works

If the input is null or an empty string, the formula will return nil. For any other data, it returns the original input data.


include?

Checks if the string contains a specific substring. Returns true if it does.

Syntax

Input.include?(substring)

  • Input - A string input.

  • substring - The substring to check for.

Sample usage

Formula

Result

"Partner account".include?("Partner")

true

"Partner account".include?("partner")

false

How it works

This formula check is the string contains a specific substring. Returns true if it does, otherwise, returns false. This substring is case sensitive.

This function acts in an opposite manner from .exclude?. It will return true only if the input string contains the stated keyword.


exclude?

Checks if the string contains a specific substring. Returns false if it does.

Syntax

Input.exclude?(substring)

  • Input - A string input.

  • substring - The substring to check for.

Sample usage

Formula

Result

"Partner account".exclude?("Partner")

false

"Partner account".exclude?("partner")

true

How it works

This formula check is the string contains a specific substring. Returns false if it does, otherwise, returns true. This substring is case sensitive.

This function acts in an opposite manner from .include?. It will return true only if the input string does NOT contain the stated keyword.


match?

Checks if the string contains a specific pattern. Returns true if it does.

Syntax

Input.match?(pattern)

  • Input - A string input.

  • pattern - The pattern to check for.

Sample usage

Formula

Result

"Jean Marie".match?(/Marie/)

true

"Jean Marie".match?(/ /)

true

"Partner account".match?(/partner/)

false

How it works

This formula check is the string contains a specific pattern. Returns true if it does, otherwise, returns false.


ends_with?

Checks if the string ends with a specific substring. Returns true if it does.

Syntax

Input.ends_with?(substring)

  • Input - A string input.

  • substring - The substring to check for.

Sample usage

Formula

Result

"Jean Marie".ends_with?("rie")

true

"Jean Marie".ends_with?("RIE")

false

"Jean Marie".upcase.ends_with?("RIE")

true

How it works

This formula check is the string ends with a specific substring. Returns true if it does, otherwise, returns false.


starts_with?

Checks if the string starts with a specific substring. Returns true if it does.

Syntax

Input.starts_with?(substring)

  • Input - A string input.

  • substring - The substring to check for.

Sample usage

Formula

Result

"Jean Marie".starts_with?("Jean")

true

"Jean Marie".starts_with?("JEAN")

false

"Jean Marie".upcase.starts_with?("JEAN")

true

How it works

This formula check is the string starts with a specific substring. Returns true if it does, otherwise, returns false.


parameterize

Replaces special characters in a string. Used when app does not accept non-standard characters.

Syntax

Input.parameterize

  • Input - An input string.

Sample usage

Formula

Result

"öüâ".parameterize

"oua"

How it works

This formula searches for special characters in the string and replaces them with standard characters. Used when app does not accept non-standard characters.


lstrip

This formula removes the white space at the beginning of the input string.

Syntax

String.lstrip

  • String - An input string.

Sample usage

Formula

Result

" Test "..lstrip

"Test "

How it works

This formula removes white spaces from the beginning of a string. If the string doesn't have any white spaces before, the input string will be returned as is.


rstrip

This formula removes the white space at the end of the input string.

Syntax

String.rstrip

  • String - An input string.

Sample usage

Formula

Result

" Test "..rstrip

" Test"

How it works

This formula removes white spaces from the end of a string. If the string doesn't have any white spaces at the end, the input string will be returned as is.


scrub

If the string is invalid byte sequence then replace invalid bytes with given replacement character, else returns self.

Syntax

String.scrub(replacement string)

  • String - An input string.

Sample usage

Formula

Result

"abc\u3042\x81".scrub("*")

"abc\u3042*"


strip

This formula removes the white space at the beginning and the end of the input string.

Syntax

String.strip

  • String - An input string.

Sample usage

Formula

Result

"Welcome to the future of automation! ".strip

"Welcome to the future of automation!"

" This is an example ".strip

"This is an example"

How it works

This formula removes white spaces from both sides of a string. If the string doesn't have any white spaces before or after, the input string will be returned as is.


strip_tags

This formula removes html tags embedded in a string.

Syntax

String.strip_tags

  • String - An input string.

Sample usage

Formula

Result

"<p>Jean Marie</p>"..strip_tags

"Jean Marie"

How it works

This formula check for html tags within the input string. It removes any html tags found and returns the string.


ljust

Aligns the string to left and pads with whitespace or pattern until string is specified length.

Syntax

String.ljust(length,character)

  • String - An input string.

  • length - The length of the output string.

  • character - (optional) The character to pad the string. If unspecified, the default pad character will be a blank space.

Sample usage

Formula

Result

"test"..ljust(5)

"test "

"test"..ljust(10, "*")

"test******"


rjust

Aligns the string to left and pads with whitespace or pattern until string is specified length.

Syntax

String.rjust(length,character)

  • String - An input string.

  • length - The length of the output string.

  • character - (optional) The character to pad the string. If unspecified, the default pad character will be a blank space.

Sample usage

Formula

Result

"test"..rjust(5)

" test"

"test"..rjust(10, "*")

"******test"


reverse

Inverts a string, reordering the characters in a backward manner. Case is preserved.

Syntax

String.reverse

  • String - An input string.

Sample usage

Formula

Result

"Jean Marie".reverse

"eiraM naeJ"

" jean marie ".reverse

" eiram naej "


gsub

Replace parts of a text string. Returns a new string with the replaced characters.

Syntax

String.gsub(find,replace)

  • String - An input string. You can use a datapill or a static string value.

  • find - The string to look for. You can use a /pattern/ syntax.

  • replace - The replacement string. You can define the replacement using a string or hash.

Sample usage

Formula

Result

"I have a blue house and a blue car".gsub("blue", "red")

"I have a red house and a red car"

"Jean Marie".gsub("J", "M")

"Mean Marie"

"Jean Marie".downcase.gsub("j", "M")

"Mean marie"

Advance sample usage

Formula

Result

"Awesome".gsub(/[Ae]/, 'A'=>'E', 'e'=>'a')

"Ewasoma"

"Anna's Cafe".gsub("'", "\\'")

"Annas Cafes Cafe"
This replaces the quotation symbol with text after breakpoint.

"Anna's Cafe".gsub("'", {"'"=>"\\'"})

"Anna\\'s Cafe"
This replace the quotation symbol with a replacement string.

How it works

This formula works like find and replace. It takes two input parameters:

  1. The first input is the string that you want to replace. This is case-sensitive, so make sure to type correctly in either uppercase or lowercase to find all occurrences that are an exact match.

  2. The second input is the new string that will be used for replacing all occurrences of first input.


sub

Replaces the first occurrence of the first input value, with the second input value, within the string. This formula is case-sensitive - make sure to type in uppercase or lowercase before comparison if you are concerned about case sensitivity.

Syntax

String.sub(find,replace)

  • String - An input string. You can use a datapill or a static string value.

  • find - The string to look for. You can use a /pattern/ syntax.

  • replace - The replacement string. You can define the replacement using a string or array.

Sample usage

Formula

Result

"Mean Marie".sub(/M/, "J")

"Jean Marie"

"Hello".sub(/[aeiou]/, "*")

"H*llo"


length

Returns the number of characters within an input string, including the white-spaces.

Syntax

String.length

  • String - An input string.

Sample usage

Formula

Result

"Jean Marie".length

10

" jean marie ".length

12


slice

Returns a partial segment of a string.

Syntax

String.slice(start,end)

  • String - An input string.

  • start - The index of the string to start returning.

  • end - (optional) The number of characters to return. If unspecified, the formula will return only one character.

Sample usage

Formula

Result

"Jean Marie".slice(0,3)

"Jea"

"Jean Marie".slice(5)

"M"

"Jean Marie".slice(3,3)

"n M"

"Jean Marie".slice(-5,5)

"Marie"

How it works

The formula returns a partial segment of a string. It takes in 2 parameters - the first parameter is the index that decides which part of the string to start returning from (first letter being 0 and subsequently progressing incrementally, negative numbers will be taken from the last character), the second parameter decides how many characters to return. If only the first parameter is passed in, only 1 character will be returned.


scan

Scan the string for the pattern to retrieve and return an array

Syntax

String.scan(pattern)

  • String - An input string.

  • pattern - The pattern to search for.

Sample usage

Formula

Result

"Thu, 01/23/2014".scan(/\d+/)

["01","23","2014"]

"Thu, 01/23/2014".scan(/\d+/).join("-")

"01-23-2014"


transliterate

Replaces non-ASCII characters with an ASCII approximation, or if none exists, a replacement character which defaults to '?'.

Syntax

String.transliterate

  • String - An input string.

Sample usage

Formula

Result

"Chloé".transliterate

"Chloe"


capitalize

Converts the input string into sentence case, i.e. the first character of each sentence is capitalized.

Syntax

String.capitalize

  • String - An input string.

Sample usage

Formula

Result

"ticket opened. Gold SLA".capitalize

"Ticket opened. gold sla"

"jean MARIE".capitalize

"Jean marie"


titleize

Converts the input string into title case, i.e. the first character of each word is capitalized.

Syntax

String.titleize

  • String - An input string.

Sample usage

Formula

Result

"ticket opened. Gold SLA".titleize

"Ticket Opened. Gold Sla"

"jean MARIE".titleize

"Jean Marie"


upcase

Convert text to uppercase.

Syntax

String.upcase

  • String - An input string.

Sample usage

Formula

Result

"Automation at it's FINEST!".upcase

"AUTOMATION AT IT'S FINEST!"

"Convert to UPCASE".upcase

"CONVERT TO UPCASE"

How it works

This formula searches for any lowercase character and replace it with the uppercase characters.


downcase

Convert text to lowercase.

Syntax

String.downcase

  • String - An input string.

Sample usage

Formula

Result

"Automation at it's FINEST!".downcase

"automation at it's finest!"

"Convert to DOWNCASE".downcase

"convert to downcase"

How it works

This formula searches for any uppercase character and replace it with the lowercase characters.

Quicktip: Search strings better with downcase

Search formulas like (gsub or sub) uses case sensitive characters. Use the downcase formula ensure that all characters are in the same case.


quote

Quotes a string, escaping any ' (single quote) characters

Syntax

String.quote

  • String - An input string.

Sample usage

Formula

Result

"Paula's Baked Goods".quote

"Paula''s Baked Goods"


split

This formula divides a string around a specified character and returns an array of strings.

Syntax

String.split(char)

  • String - An input string value. You can use a datapill or a static value.

  • char - (optional) The character at which to split the text. This is case sensitive. If no character is defined, then by default, strings are split by white spaces.

Sample usage

Formula

Result

"Ms-Jean-Marie".split("-")

["Ms", "Jean", "Marie"]

"Ms Jean Marie".split

["Ms", "Jean", "Marie"]

"Split string".split()

["Split", "string"]

"Split string".split("t")

["Spli", " s", "ring"]

"01/23/2014".split("/")

["01", "23", "2014"]

"01/23/2014".split("/").join("-")

"01-23-2014"

How it works

This formula looks for the specified character in the input string. Every time it is found, the input will be split into a new string.


bytes

Returns an array of bytes for a given string.

Syntax

String.bytes

  • String - An input string.

Sample usage

Formula

Result

"Hello".bytes

["72","101","108","108","111"]


bytesize

Returns the length of a given string in bytes.

Syntax

Input.bytesize

  • Input - Any input string.

Sample usage

Formula

Result

"Hello".bytesize

5


byteslice

Returns a substring of specified bytes instead of length. In some cases, non ASCII characters (Japanese, Chinese e.g.) may use multiple bytes.

Syntax

Input.byteslice(0,4)

  • Input - Any input string.

Sample usage

Formula

Result

"hello".byeslice(1)

e

"hello".byeslice(-1)

o

"hello".byeslice(1,2)

el

"abc漢字".byeslice(0,4)

abc漢


to_s

Converts data to a string (text) datatype.

Syntax

Input.to_s

  • Input - Any input data. You can use number, array, object, or datetime datatypes.

Sample usage

Formula

Result

-45.67.to_s

"-45.67"

"123".to_s

"123"

[1,2,3].to_s

"[1,2,3]"

{key: "Automate"}.to_s

"{:key=>"Automate"}""

"2020-06-05T17:13:27.000000-07:00".to_s

"2020-06-05T17:13:27.000000-07:00"

"2020-06-05T17:13:27.000000-07:00".to_s(:short)

"05 Jun 17:13"

"2020-06-05T17:13:27.000000-07:00".to_s(:long)

"June 05, 2020 17:13"

How it works

This formula returns a string representation of the input data.


ordinalize

Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

Syntax

Input.ordinalize

  • Input - Any input number.

Sample usage

Formula

Result

1.ordinalize

"1st"

2.ordinalize

"2nd"

3.ordinalize

"3rd"

1003.ordinalize

"1003rd"

-3.ordinalize

"-3rd"


to_f

Converts data to a float (number) datatype.

Syntax

Input.to_f

  • Input - A number input data. You can use a string datatype or an integer datatype.

Sample usage

Formula

Result

45.to_f

45.0

-45.to_f

-45.0

"45.67".to_f

45.67

"Automate".to_f

0

How it works

This formula checks whether the input contains any numbers, if no numbers are found, it returns 0. If the number does not have a decimal point, .0 will be added the number.


to_i

Converts data to an integer (whole number) datatype.

Syntax

Input.to_i

  • Input - A number input data. You can use a string datatype or a float datatype.

Sample usage

Formula

Result

45.43.to_i

45

-45.43.to_i

-45

"123".to_i

123

"Automate".to_i

0

How it works

This formula checks whether the input contains any numbers, if no numbers are found, it returns 0. If the number has a decimal point, everything after the decimal will be omitted.


to_country_alpha2

Convert alpha-3 country code or country name to alpha2 country code (first 2 initials).

Syntax

Input.to_country_alpha2

  • Input - Any input string.

Sample usage

Formula

Result

"GBR".to_country_alpha2

"GB"

"United Kingdom".to_country_alpha2

"GB"


to_country_alpha3

Convert alpha-2 country code or country name to alpha3 country code (first 3 initials).

Syntax

Input.to_country_alpha3

  • Input - Any input string.

Sample usage

Formula

Result

"GBR".to_country_alpha3

"GBR"

"United Kingdom".to_country_alpha3

"GBR"


tocountryname

Convert alpha-2/3 country code or country name to ISO3166 country name.

Syntax

Input.to_country_name

  • Input - Any input string.

Sample usage

Formula

Result

"GBR".to_country_name

"United Kingdom"

"GB".to_country_name

"United Kingdom"


to_currency

Formats integers/numbers to a currency-style.

Syntax

Input.to_currency

  • Input - Any input string.

Sample usage

Formula

Description

Result

"345.60".to_currency

Adds default currency symbol "$"

"$345.60"


to_currency_code

Convert alpha-2/3 country code or country name to ISO4217 currency code

Syntax

Input.to_currency_code

  • Input - Any input string.

Sample usage

Formula

Result

"GBR".to_currency_code

"GBP"

"US".to_currency_code

"USD"


to_currency_name

Convert alpha-3 currency code or alpha-2/3 country code or country name to ISO4217 currency name.

Syntax

Input.to_currency_name

  • Input - Any input string.

Sample usage

Formula

Result

"GBR".to_currency_code

"Pound"

"USD".to_currency_code

"Dollars"


to_currency_symbol

Convert alpha-3 currency code or alpha-2/3 country code or country name to ISO4217 currency symbol.

Syntax

Input.to_currency_symbol

  • Input - Any input string.

Sample usage

Formula

Result

"GBR".to_currency_symbol

"£"

"USD".to_currency_symbol

"$"


to_phone

Converts string or number to a formatted phone number (user-defined).

Syntax

Input.to_phone

  • Input - Any input string or number.

Sample usage

Formula

Result

"5551234".to_phone

555-1234

1235551234.to_phone

123-555-1234

1235551234.to_phone(area_code: true)

(123) 555-1234

1235551234.to_phone(delimiter: " ")

123 555 1234

1235551234.to_phone(area_code: true, extension: 555)

(123) 555-1234 x 555

1235551234.to_phone(country_code: 1)

+1-123-555-1234

"123a456".to_phone

123a456


to_state_code

Convert state name to code.

Syntax

Input.to_state_code

  • Input - Any input string.

Sample usage

Formula

Result

"California".to_state_code

CA


to_state_name

Convert state code to name.

Syntax

Input.to_state_name

  • Input - Any input string.

Sample usage

Formula

Result

"CA".to_state_name

CALIFORNIA

Did this answer your question?