magic.lambda.strings
This project contains string manipulation slots for Magic. More specifically, it gives you the following slots.
- [strings.replace] - Replaces occurrences of the specified argument with the value of its specified argument
- [strings.replace-not-of] - Replaces all characters found in string, except those found in its single argument
- [strings.capitalize] - Turns the first character in your string into a CAPS
- [strings.concat] - Concatenates two or more strings
- [strings.contains] - Returns true if specified string contains the given argument
- [strings.ends-with] - Returns true if the specified string ends with the specified argument
- [strings.starts-with] - Returns true if the specified string starts with its argument
- [strings.join] - Joins multiple strings together, with a separating string between each string joined
- [strings.length] - Returns the length in characters of the given string
- [strings.byte-count] - Returns the UTF-8 byte length of the given string
- [strings.regex-replace] - Replaces occurrences matching the given regular expression with its argument
- [strings.split] - Splits a string into multiple strings on every match of its given argument
- [strings.to-lower] - Returns the lower caps version of its given argument
- [strings.to-upper] - Returns the upper caps version of its specified argument
- [strings.trim] - Trims a string, optionally for all characters found in its argument
- [strings.trim-start] - Trims a string only to its left, optionally for all characters found in its argument
- [strings.trim-end] - Trims a string only to its right, optionally for all characters found in its argument
- [strings.url-encode] - URL encodes the specified string
- [strings.url-decode] - URL decodes the specified string
- [strings.html-encode] - HTML encodes the specified string
- [strings.html-decode] - HTML decodes the specified string
- [strings.substring] - Returns the sub-string of the specified string
- [strings.matches] - Returns the regular expression matches found from specified source
- [strings.mixin] - Allows for mixin logic of strings and Hyperlambda
- [strings.builder] - Creates a string builder scope for [strings.builder.append]
- [strings.builder.append] - Appends text to the current [strings.builder] scope
Usage
All the above slots that require two arguments, will use the first argument as its “what” argument, and the second as its “with” argument. Avoiding naming these though, allows you to reference other slots, and use these as sources to parametrize your invocations to the above slots. Below is an example of how this would look like.
.data:Hyperlambda is cool
strings.replace:x:-
.:cool
.:super cool