Strings { @UserFunction @Description("apoc.text.split(text, regex, limit) - splits the given text around matches of the given regex.") public List<String> split(final @Name("text") String text, final @Name("regex") String regex, final @Name(value = "limit", defaultValue = "0") Long limit) { if (text == null || regex == null || limit == null) { return null; } String[] resultArray = text.split(regex, limit.intValue()); return new ArrayList<>(asList(resultArray)); }  @UserFunction @Description("apoc.text.indexOf(text, lookup, from=0, to=-1==len) - find the first occurence of the lookup string in the text, from inclusive, to exclusive, -1 if not found, null if text is null.") Long indexOf(final @Name("text") String text, final @Name("lookup") String lookup, final @Name(value = "from",defaultValue="0") long from, @Name(value = "to",defaultValue="-1") long to); @UserFunction @Description("apoc.text.indexesOf(text, lookup, from=0, to=-1==len) - finds all occurences of the lookup string in the text, return list, from inclusive, to exclusive, empty list if not found, null if text is null.") List<Long> indexesOf(final @Name("text") String text, final @Name("lookup") String lookup, final @Name(value = "from", defaultValue = "0") long from, @Name(value = "to", defaultValue = "-1") long to); @UserFunction @Description("apoc.text.replace(text, regex, replacement) - replace each substring of the given string that matches the given regular expression with the given replacement.") String replace(final @Name("text") String text, final @Name("regex") String regex, final @Name("replacement") String replacement); @UserFunction @Description("apoc.text.byteCount(text,[charset]) - return size of text in bytes") long byteCount(final @Name("text") String text, @Name(value = "charset", defaultValue = "UTF-8") String charset); @UserFunction @Description("apoc.text.bytes(text,[charset]) - return bytes of the text") List<Long> bytes(final @Name("text") String text, @Name(value = "charset", defaultValue = "UTF-8") String charset); @UserFunction @Description("apoc.text.regreplace(text, regex, replacement) - replace each substring of the given string that matches the given regular expression with the given replacement.") String regreplace(final @Name("text") String text, final @Name("regex") String regex, final @Name("replacement") String replacement); @UserFunction @Description("apoc.text.split(text, regex, limit) - splits the given text around matches of the given regex.") List<String> split(final @Name("text") String text, final @Name("regex") String regex, final @Name(value = "limit", defaultValue = "0") Long limit); @UserFunction @Description("apoc.text.regexGroups(text, regex) - return all matching groups of the regex on the given text.") List<List<String>> regexGroups(final @Name("text") String text, final @Name("regex") String regex); @UserFunction @Description("apoc.text.join(['text1','text2',...], delimiter) - join the given strings with the given delimiter.") String join(
            final @Name("texts") List<String> texts,
            final @Name("delimiter") String delimiter); @UserFunction @Description("apoc.text.clean(text) - strip the given string of everything except alpha numeric characters and convert it to lower case.") String clean(final @Name("text") String text); @UserFunction @Description("apoc.text.compareCleaned(text1, text2) - compare the given strings stripped of everything except alpha numeric characters converted to lower case.") boolean compareCleaned(final @Name("text1") String text1, final @Name("text2") String text2); @UserFunction @Description("apoc.text.distance(text1, text2) - compare the given strings with the Levenshtein distance algorithm.") Long distance(final @Name("text1") String text1, @Name("text2")final String text2); @UserFunction @Description("apoc.text.levenshteinDistance(text1, text2) - compare the given strings with the Levenshtein distance algorithm.") Long levenshteinDistance(final @Name("text1") String text1, @Name("text2")final String text2); @UserFunction @Description( "apoc.text.levenshteinSimilarity(text1, text2) - calculate the similarity (a value within 0 and 1) between two texts." ) Double levenshteinSimilarity(final @Name("text1") String text1, @Name("text2")final String text2); @UserFunction @Description( "apoc.text.hammingDistance(text1, text2) - compare the given strings with the Hamming distance algorithm." ) Long hammingDistance(final @Name("text1") String text1, @Name("text2")final String text2); @UserFunction @Description( "apoc.text.jaroWinklerDistance(text1, text2) - compare the given strings with the Jaro-Winkler distance algorithm." ) Double jaroWinklerDistance(final @Name("text1") String text1, @Name("text2")final String text2); @UserFunction @Description("apoc.text.sorensenDiceSimilarityWithLanguage(text1, text2, languageTag) - compare the given strings with the Sørensen–Dice coefficient formula, with the provided IETF language tag") Double sorensenDiceSimilarity(final @Name("text1") String text1, final @Name("text2") String text2, final @Name(value = "languageTag", defaultValue = "en") String languageTag); @UserFunction @Description("apoc.text.fuzzyMatch(text1, text2) - check if 2 words can be matched in a fuzzy way. Depending on the" + " length of the String it will allow more characters that needs to be edited to match the second String.") Boolean fuzzyMatch(final @Name("text1") String text1, @Name("text2")final String text2); @UserFunction @Description("apoc.text.urlencode(text) - return the urlencoded text") String urlencode(@Name("text") String text); @UserFunction @Description("apoc.text.urldecode(text) - return the urldecoded text") String urldecode(@Name("text") String text); @UserFunction @Description("apoc.text.lpad(text,count,delim) YIELD value - left pad the string to the given width") String lpad(@Name("text") String text, @Name("count") long count,@Name(value = "delim",defaultValue = " ") String delim); @UserFunction @Description("apoc.text.rpad(text,count,delim) YIELD value - right pad the string to the given width") String rpad(@Name("text") String text, @Name("count") long count, @Name(value = "delim",defaultValue = " ") String delim); @UserFunction @Description("apoc.text.format(text,[params],language) - sprintf format the string with the params given") String format(@Name("text") String text, @Name("params") List<Object> params, @Name(value = "language",defaultValue = "en") String lang); @UserFunction @Description("apoc.text.slug(text, delim) - slug the text with the given delimiter") String slug(@Name("text") String text, @Name(value = "delim", defaultValue = "-") String delim); @UserFunction @Description("apoc.text.random(length, valid) YIELD value - generate a random string") String random(final @Name("length") long length, @Name(value = "valid", defaultValue = "A-Za-z0-9") String valid); @UserFunction @Description("apoc.text.capitalize(text) YIELD value - capitalise the first letter of the word") String capitalize(@Name("text") String text); @UserFunction @Description("apoc.text.capitalizeAll(text) YIELD value - capitalise the first letter of every word in the text") String capitalizeAll(@Name("text") String text); @UserFunction @Description("apoc.text.decapitalize(text) YIELD value - decapitalize the first letter of the word") String decapitalize(@Name("text") String text); @UserFunction @Description("apoc.text.decapitalizeAll(text) YIELD value - decapitalize the first letter of all words") String decapitalizeAll(@Name("text") String text); @UserFunction @Description("apoc.text.swapCase(text) YIELD value - Swap the case of a string") String swapCase(@Name("text") String text); @UserFunction @Description("apoc.text.camelCase(text) YIELD value - Convert a string to camelCase") String camelCase(@Name("text") String text); @UserFunction @Description("apoc.text.upperCamelCase(text) YIELD value - Convert a string to camelCase") String upperCamelCase(@Name("text") String text); @UserFunction @Description("apoc.text.snakeCase(text) YIELD value - Convert a string to snake-case") String snakeCase(@Name("text") String text); @UserFunction @Description("apoc.text.toUpperCase(text) YIELD value - Convert a string to UPPER_CASE") String toUpperCase(@Name("text") String text); @UserFunction @Description("apoc.text.base64Encode(text) YIELD value - Encode a string with Base64") String base64Encode(@Name("text") String text); @UserFunction @Description("apoc.text.base64Decode(text) YIELD value - Decode Base64 encoded string") String base64Decode(@Name("text") String text); @UserFunction @Description("apoc.text.base64UrlEncode(text) YIELD value - Encode a url with Base64") String base64UrlEncode(@Name("url") String url); @UserFunction @Description("apoc.text.base64UrlDecode(url) YIELD value - Decode Base64 encoded url") String base64UrlDecode(@Name("url") String url); @UserFunction @Description("apoc.text.charAt(text, index) - the decimal value of the character at the given index") Long charAt(@Name("text") String text, @Name("index") Long index); @UserFunction @Description("apoc.text.code(codepoint) - Returns the unicode character of the given codepoint") String code(@Name("codepoint") Long codepoint); @UserFunction @Description("apoc.text.hexValue(value) - the hex value string of the given number") String hexValue(@Name("value") Long value); @UserFunction @Description("apoc.text.hexCharAt(text, index) - the hex value string of the character at the given index") String hexCharAt(@Name("text") String text, @Name("index") Long index); @UserFunction @Description("apoc.text.toCypher(value, {skipKeys,keepKeys,skipValues,keepValues,skipNull,node,relationship,start,end}) | tries it's best to convert the value to a cypher-property-string") String toCypher(@Name("value") Object value, @Name(value = "config",defaultValue = "{}") Map<String,Object> config); @UserFunction @Description("apoc.text.repeat(item, count) - string multiplication") String repeat(@Name("item") String item, @Name("count") long count); @Context
    public Transaction tx; }
@Test public void testSplit() throws Exception { String text = "1, 2, 3,4"; String regex = ", *"; testCall(db, "RETURN apoc.text.split($text, $regex) AS value", map("text", text, "regex", regex), row -> assertEquals(asList("1", "2", "3", "4"), row.get("value"))); testCall(db, "RETURN apoc.text.split($text, $regex, 2) AS value", map("text", text, "regex", regex), row -> assertEquals(asList("1", "2, 3,4"), row.get("value"))); }