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 ¶
- func Base64Decode(text string) string
- func Base64Encode(text string) string
- func Bytes(text string) []byte
- func BytesToString(bytes []byte) string
- func CamelCase(text string) string
- func Capitalize(text string) string
- func CapitalizeAll(text string) string
- func Clean(text string) string
- func Code(text string) int
- func CompareCleaned(text1, text2 string) bool
- func Decapitalize(text string) string
- func DecapitalizeAll(text string) string
- func Distance(s1, s2 string) int
- func DoubleMetaphone(text string) []string
- func Format(format string, args []interface{}) string
- func FromCodePoint(code int) string
- func FuzzyMatch(s1, s2 string, threshold float64) bool
- func HammingDistance(s1, s2 string) int
- func IndexOf(text, substring string) int
- func IndexesOf(text, substring string) []int
- func JaroWinklerDistance(s1, s2 string) float64
- func Join(strs []string, delimiter string) string
- func Lpad(text string, length int, pad string) string
- func Ltrim(text string) string
- func Phonetic(text string) string
- func PhoneticDelta(s1, s2 string) int
- func RegexGroups(text, pattern string) [][]string
- func Repeat(text string, count int) string
- func Replace(text, old, new string) string
- func Reverse(text string) string
- func Rpad(text string, length int, pad string) string
- func Rtrim(text string) string
- func Slug(text string) string
- func SnakeCase(text string) string
- func SorensenDiceSimilarity(s1, s2 string) float64
- func Split(text, delimiter string) []string
- func SwapCase(text string) string
- func Trim(text string) string
- func UpperCamelCase(text string) string
- func Urldecode(text string) string
- func Urlencode(text string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64Decode decodes a base64 string.
Example:
apoc.text.base64Decode('aGVsbG8=') => 'hello'
func Base64Encode ¶
Base64Encode encodes a string to base64.
Example:
apoc.text.base64Encode('hello') => 'aGVsbG8='
func Bytes ¶
Bytes returns the byte representation of a string.
Example:
apoc.text.bytes('hello') => [104, 101, 108, 108, 111]
func BytesToString ¶
BytesToString converts bytes to a string.
Example:
apoc.text.bytesToString([104, 101, 108, 108, 111]) => 'hello'
func CamelCase ¶
CamelCase converts text to camelCase.
Example:
apoc.text.camelCase('hello world') => 'helloWorld'
apoc.text.camelCase('hello_world') => 'helloWorld'
func Capitalize ¶
Capitalize capitalizes the first letter of each word.
Example:
apoc.text.capitalize('hello world') => 'Hello World'
func CapitalizeAll ¶
CapitalizeAll capitalizes all letters.
Example:
apoc.text.capitalizeAll('hello world') => 'HELLO WORLD'
func Clean ¶
Clean removes extra whitespace and trims.
Example:
apoc.text.clean(' hello world ') => 'hello world'
func Code ¶
Code returns the Unicode code point of the first character.
Example:
apoc.text.code('A') => 65
func CompareCleaned ¶
Comparecleanstrings compares two strings after cleaning.
Example:
apoc.text.compareCleaned(' Hello ', 'hello') => true
func Decapitalize ¶
Decapitalize makes the first letter lowercase.
Example:
apoc.text.decapitalize('Hello World') => 'hello World'
func DecapitalizeAll ¶
DecapitalizeAll makes all letters lowercase.
Example:
apoc.text.decapitalizeAll('HELLO WORLD') => 'hello world'
func Distance ¶
Distance calculates Levenshtein distance between two strings.
Example:
apoc.text.distance('kitten', 'sitting') => 3
func DoubleMetaphone ¶
Doublemet aphonetic encoding (Double Metaphone).
Example:
apoc.text.doubleMetaphone('Smith') => ['SM0', 'XMT']
func Format ¶
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 ¶
FromCodePoint returns a string from a Unicode code point.
Example:
apoc.text.fromCodePoint(65) => 'A'
func FuzzyMatch ¶
FuzzyMatch checks if strings are similar within a threshold.
Example:
apoc.text.fuzzyMatch('hello', 'helo') => true
func HammingDistance ¶
Hammingdistance calculates Hamming distance (for equal-length strings).
Example:
apoc.text.hammingDistance('karolin', 'kathrin') => 3
func IndexOf ¶
IndexOf returns the index of the first occurrence of a substring.
Example:
apoc.text.indexOf('hello world', 'world') => 6
func IndexesOf ¶
IndexesOf returns all indexes of a substring.
Example:
apoc.text.indexesOf('hello hello', 'hello') => [0, 6]
func JaroWinklerDistance ¶
JaroWinklerDistance calculates Jaro-Winkler similarity.
Example:
apoc.text.jaroWinklerDistance('martha', 'marhta') => 0.96
func Join ¶
Join joins a list of strings with a delimiter.
Example:
apoc.text.join(['Hello', 'World'], ' ') => 'Hello World'
func Lpad ¶
Lpad pads a string on the left to a given length.
Example:
apoc.text.lpad('5', 3, '0') => '005'
func Phonetic ¶
Phonetic returns a phonetic encoding (Soundex).
Example:
apoc.text.phonetic('Smith') => 'S530'
func PhoneticDelta ¶
PhoneticDelta calculates phonetic similarity.
Example:
apoc.text.phoneticDelta('Smith', 'Smythe') => 0 (same soundex)
func RegexGroups ¶
RegexGroups extracts regex capture groups.
Example:
apoc.text.regexGroups('abc123def', '([a-z]+)([0-9]+)([a-z]+)')
=> [['abc123def', 'abc', '123', 'def']]
func Replace ¶
Replace replaces all occurrences of a substring.
Example:
apoc.text.replace('Hello World', 'World', 'Universe')
=> 'Hello Universe'
func Rpad ¶
Rpad pads a string on the right to a given length.
Example:
apoc.text.rpad('5', 3, '0') => '500'
func Slug ¶
Slug converts text to a URL-friendly slug.
Example:
apoc.text.slug('Hello World!') => 'hello-world'
func SnakeCase ¶
SnakeCase converts text to snake_case.
Example:
apoc.text.snakeCase('HelloWorld') => 'hello_world'
apoc.text.snakeCase('hello world') => 'hello_world'
func SorensenDiceSimilarity ¶
SorensenDiceSimilarity calculates Sørensen-Dice coefficient.
Example:
apoc.text.sorensenDiceSimilarity('night', 'nacht') => 0.25
func Split ¶
Split splits a string by a delimiter.
Example:
apoc.text.split('Hello World', ' ') => ['Hello', 'World']
func SwapCase ¶
SwapCase swaps the case of all letters.
Example:
apoc.text.swapCase('Hello World') => 'hELLO wORLD'
func Trim ¶
Trim removes leading and trailing whitespace.
Example:
apoc.text.trim(' hello ') => 'hello'
func UpperCamelCase ¶
UpperCamelCase converts text to UpperCamelCase (PascalCase).
Example:
apoc.text.upperCamelCase('hello world') => 'HelloWorld'
Types ¶
This section is empty.