Placeholder

Customer Forum

Returning a sub-string from a string

Workbooks Support Posted: 2014-07-02 10:47

We were recently asked to create a formula which returns the domain for email addresses. For example, 'support@workbooks.com' would return 'workbooks.com'. You can do this using the Substring Index formula.

  • SUBSTRING_INDEX(str, delim, count)

This will return the substring from a string 'str' before, 'count' occurrences of the delimiter 'delim'. If 'count' is positive, everything to the left of the final delimiter (counting from the left) is returned. If 'count' is negative, everything to the right of the final delimiter (counting from the right) is returned.

In our example you would use the following formula:

  • SUBSTRING_INDEX(main_email, '@', '-1')

This formula says find the first instance of the '@' symbol and return everything to the right, with counting starting from the right. If we had set the count to '1', this would return everything to the left of the first instance of the '@' symbol (support).