Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

4.1 KB
Raw Blame
print('-- empty, notEmpty, length, lower, upper, reverse --')
if (empty('') and notEmpty('234')) print(length('123'))
if (lower('Tdd4gh') == 'tdd4gh') print(upper('test'))
print(lower(null))
print(reverse('spinner'))
print('')
print('-- encodeURLComponent, decodeURLComponent --')
print(encodeURLComponent('http://www.google.com'))
print(encodeURLComponent('tom & jerry'))
print(decodeURLComponent(encodeURLComponent('http://www.google.com')))
print(decodeURLComponent(encodeURLComponent('tom & jerry')))
print('')
print('-- base64Encode, base64Decode --')
print(base64Encode('http://www.google.com'))
print(base64Encode('tom & jerry'))
print(base64Decode(base64Encode('http://www.google.com')))
print(base64Decode(base64Encode('tom & jerry')))
print('')
print('-- empty --')
print(empty(null))
print(empty(0))
print(empty(1))
print(empty(-1))
print(empty(0.0))
print(empty(0.01))
print(empty(''))
print(empty('string'))
print(empty('0'))
print(empty([]))
print(empty({}))
print(empty(tuple()))
print(empty(tuple(0)))
print(empty(tuple(1,2)))
print(empty(true))
print(empty(false))
print('')
print('-- notEmpty --')
print(notEmpty(null))
print(notEmpty(0))
print(notEmpty(1))
print(notEmpty(-1))
print(notEmpty(0.0))
print(notEmpty(0.01))
print(notEmpty(''))
print(notEmpty('string'))
print(notEmpty('0'))
print(notEmpty([]))
print(notEmpty({}))
print(notEmpty(tuple()))
print(notEmpty(tuple(0)))
print(notEmpty(tuple(1,2)))
print(notEmpty(true))
print(notEmpty(false))
print('')
print('-- replaceAll, replaceOne --')
print(replaceAll('hello world', 'l', 'L'))
print(replaceOne('hello world', 'l', 'L'))
print('')
print('-- generateUUIDv4 --')
print(length(generateUUIDv4()))
print('')
print('-- isNull, isNotNull --')
print(isNull(null), isNotNull(null))
print(isNull(true), isNotNull(true))
print(isNull('banana'), isNotNull('banana'))
print(isNull(false), isNotNull(false))
print(isNull(0), isNotNull(0))
print(isNull(1), isNotNull(1))
print('')
print('-- comparisons --')
print(equals(1,1), equals(1,2), equals(1, '1'))
print(notEquals(2,3), not(true))
print(greater(2,1), greaterOrEquals(2,2))
print(less(1,2), lessOrEquals(2,2), less(-3, 2))
print(or(false, true), or(0, 0), or(1, 0), or(1, false), or(0, false), or(1), or('string'), or(100))
print(and(false, true), and(0, 0), and(1, 0), and(1, false), and(0, false), and(1, 1), and(1), and(true), and('string'), and(100))
print('')
print('-- logic --')
print(if(true, 'yes', 'no'), if(false, 'yes', 'no'))
print(multiIf(true, 'one', false, 'two', 'default'))
print('')
print('-- math --')
print(min2(3,5))
print(plus(10,5), minus(10,5))
print(floor(3.99), round(3.5))
print(range(5))
print(range(3,6))
print('')
print('-- string/array --')
print(in('a', tuple('a','b','c')), in('z', tuple('a','b','c')))
print(in('a', ['a','b','c']), in('z', ['a','b','c']))
print(startsWith('hello','he'), substring('abcdef',2,3))
print(substring('abcdef',2))
print(coalesce(null, null, 'firstNonNull'), assumeNotNull('notNull'))
print('')
print('-- date --')
print(toYear(toDateTime('2024-12-18T00:00:00Z')), toMonth(toDateTime('2024-12-18T00:00:00Z')))
print(typeof(now()))
print(toStartOfDay(toDateTime('2024-12-18T11:11:11Z')), toStartOfWeek(toDateTime('2024-12-18T11:11:11Z')))
print(toYYYYMM(toDateTime('2024-12-18T00:00:00Z')))
print(dateAdd('day', 1, toDate('2024-12-18')), dateDiff('day', toDate('2024-12-18'), dateAdd('day', 5, toDate('2024-12-18'))))
print(dateTrunc('day', toDateTime('2024-12-18T12:34:56Z')))
print(addDays(toDate('2024-12-18'), 3))
print(toIntervalDay(5), toIntervalMonth(2))
print(typeof(today()))
print('')
print('-- json --')
print(jsonStringify(JSONExtractInt('{"a":123.1}', 'a')), jsonStringify(JSONExtractInt('{"a":"hello"}','a')))
print(jsonStringify(JSONExtractFloat('{"a":123.1}', 'a')), jsonStringify(JSONExtractFloat('{"a":"hello"}','a')))
print(jsonStringify(JSONExtractString('{"a":123.1}', 'a')), jsonStringify(JSONExtractString('{"a":"hello"}','a')))
print(jsonStringify(JSONExtractArrayRaw('{"a":123}', 'a')), jsonStringify(JSONExtractArrayRaw('{"a":"hello"}','a')))
print(jsonStringify(JSONExtractArrayRaw('{"a":[]}', 'a')), jsonStringify(JSONExtractArrayRaw('{"a":["hello"]}','a')))