text

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package text provides APOC text processing functions.

This package implements all apoc.text.* functions for string manipulation and text processing in Cypher queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(text string) string

Base64Decode decodes a base64 string.

Example:

apoc.text.base64Decode('aGVsbG8=') => 'hello'

func Base64Encode

func Base64Encode(text string) string

Base64Encode encodes a string to base64.

Example:

apoc.text.base64Encode('hello') => 'aGVsbG8='

func Bytes

func Bytes(text string) []byte

Bytes returns the byte representation of a string.

Example:

apoc.text.bytes('hello') => [104, 101, 108, 108, 111]

func BytesToString

func BytesToString(bytes []byte) string

BytesToString converts bytes to a string.

Example:

apoc.text.bytesToString([104, 101, 108, 108, 111]) => 'hello'

func CamelCase

func CamelCase(text string) string

CamelCase converts text to camelCase.

Example:

apoc.text.camelCase('hello world') => 'helloWorld'
apoc.text.camelCase('hello_world') => 'helloWorld'

func Capitalize

func Capitalize(text string) string

Capitalize capitalizes the first letter of each word.

Example:

apoc.text.capitalize('hello world') => 'Hello World'

func CapitalizeAll

func CapitalizeAll(text string) string

CapitalizeAll capitalizes all letters.

Example:

apoc.text.capitalizeAll('hello world') => 'HELLO WORLD'

func Clean

func Clean(text string) string

Clean removes extra whitespace and trims.

Example:

apoc.text.clean('  hello   world  ') => 'hello world'

func Code

func Code(text string) int

Code returns the Unicode code point of the first character.

Example:

apoc.text.code('A') => 65

func CompareCleaned

func CompareCleaned(text1, text2 string) bool

Comparecleanstrings compares two strings after cleaning.

Example:

apoc.text.compareCleaned('  Hello  ', 'hello') => true

func Decapitalize

func Decapitalize(text string) string

Decapitalize makes the first letter lowercase.

Example:

apoc.text.decapitalize('Hello World') => 'hello World'

func DecapitalizeAll

func DecapitalizeAll(text string) string

DecapitalizeAll makes all letters lowercase.

Example:

apoc.text.decapitalizeAll('HELLO WORLD') => 'hello world'

func Distance

func Distance(s1, s2 string) int

Distance calculates Levenshtein distance between two strings.

Example:

apoc.text.distance('kitten', 'sitting') => 3

func DoubleMetaphone

func DoubleMetaphone(text string) []string

Doublemet aphonetic encoding (Double Metaphone).

Example:

apoc.text.doubleMetaphone('Smith') => ['SM0', 'XMT']

func Format

func Format(format string, args []interface{}) string

Format formats a string using placeholders.

Example:

apoc.text.format('Hello %s, you are %d years old', ['Alice', 30])
=> 'Hello Alice, you are 30 years old'

func FromCodePoint

func FromCodePoint(code int) string

FromCodePoint returns a string from a Unicode code point.

Example:

apoc.text.fromCodePoint(65) => 'A'

func FuzzyMatch

func FuzzyMatch(s1, s2 string, threshold float64) bool

FuzzyMatch checks if strings are similar within a threshold.

Example:

apoc.text.fuzzyMatch('hello', 'helo') => true

func HammingDistance

func HammingDistance(s1, s2 string) int

Hammingdistance calculates Hamming distance (for equal-length strings).

Example:

apoc.text.hammingDistance('karolin', 'kathrin') => 3

func IndexOf

func IndexOf(text, substring string) int

IndexOf returns the index of the first occurrence of a substring.

Example:

apoc.text.indexOf('hello world', 'world') => 6

func IndexesOf

func IndexesOf(text, substring string) []int

IndexesOf returns all indexes of a substring.

Example:

apoc.text.indexesOf('hello hello', 'hello') => [0, 6]

func JaroWinklerDistance

func JaroWinklerDistance(s1, s2 string) float64

JaroWinklerDistance calculates Jaro-Winkler similarity.

Example:

apoc.text.jaroWinklerDistance('martha', 'marhta') => 0.96

func Join

func Join(strs []string, delimiter string) string

Join joins a list of strings with a delimiter.

Example:

apoc.text.join(['Hello', 'World'], ' ') => 'Hello World'

func Lpad

func Lpad(text string, length int, pad string) string

Lpad pads a string on the left to a given length.

Example:

apoc.text.lpad('5', 3, '0') => '005'

func Ltrim

func Ltrim(text string) string

Ltrim removes leading whitespace.

Example:

apoc.text.ltrim('  hello  ') => 'hello  '

func Phonetic

func Phonetic(text string) string

Phonetic returns a phonetic encoding (Soundex).

Example:

apoc.text.phonetic('Smith') => 'S530'

func PhoneticDelta

func PhoneticDelta(s1, s2 string) int

PhoneticDelta calculates phonetic similarity.

Example:

apoc.text.phoneticDelta('Smith', 'Smythe') => 0 (same soundex)

func RegexGroups

func RegexGroups(text, pattern string) [][]string

RegexGroups extracts regex capture groups.

Example:

apoc.text.regexGroups('abc123def', '([a-z]+)([0-9]+)([a-z]+)')
=> [['abc123def', 'abc', '123', 'def']]

func Repeat

func Repeat(text string, count int) string

Repeat repeats a string n times.

Example:

apoc.text.repeat('ab', 3) => 'ababab'

func Replace

func Replace(text, old, new string) string

Replace replaces all occurrences of a substring.

Example:

apoc.text.replace('Hello World', 'World', 'Universe')
=> 'Hello Universe'

func Reverse

func Reverse(text string) string

Reverse reverses a string.

Example:

apoc.text.reverse('hello') => 'olleh'

func Rpad

func Rpad(text string, length int, pad string) string

Rpad pads a string on the right to a given length.

Example:

apoc.text.rpad('5', 3, '0') => '500'

func Rtrim

func Rtrim(text string) string

Rtrim removes trailing whitespace.

Example:

apoc.text.rtrim('  hello  ') => '  hello'

func Slug

func Slug(text string) string

Slug converts text to a URL-friendly slug.

Example:

apoc.text.slug('Hello World!') => 'hello-world'

func SnakeCase

func SnakeCase(text string) string

SnakeCase converts text to snake_case.

Example:

apoc.text.snakeCase('HelloWorld') => 'hello_world'
apoc.text.snakeCase('hello world') => 'hello_world'

func SorensenDiceSimilarity

func SorensenDiceSimilarity(s1, s2 string) float64

SorensenDiceSimilarity calculates Sørensen-Dice coefficient.

Example:

apoc.text.sorensenDiceSimilarity('night', 'nacht') => 0.25

func Split

func Split(text, delimiter string) []string

Split splits a string by a delimiter.

Example:

apoc.text.split('Hello World', ' ') => ['Hello', 'World']

func SwapCase

func SwapCase(text string) string

SwapCase swaps the case of all letters.

Example:

apoc.text.swapCase('Hello World') => 'hELLO wORLD'

func Trim

func Trim(text string) string

Trim removes leading and trailing whitespace.

Example:

apoc.text.trim('  hello  ') => 'hello'

func UpperCamelCase

func UpperCamelCase(text string) string

UpperCamelCase converts text to UpperCamelCase (PascalCase).

Example:

apoc.text.upperCamelCase('hello world') => 'HelloWorld'

func Urldecode

func Urldecode(text string) string

Urldecode decodes a URL-encoded string.

Example:

apoc.text.urldecode('hello+world') => 'hello world'

func Urlencode

func Urlencode(text string) string

Urlencode encodes a string for use in URLs.

Example:

apoc.text.urlencode('hello world') => 'hello+world'

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL