magic.lambda.strings 15.9.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.lambda.strings --version 15.9.1                
NuGet\Install-Package magic.lambda.strings -Version 15.9.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.lambda.strings" Version="15.9.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.strings --version 15.9.1                
#r "nuget: magic.lambda.strings, 15.9.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.lambda.strings as a Cake Addin
#addin nuget:?package=magic.lambda.strings&version=15.9.1

// Install magic.lambda.strings as a Cake Tool
#tool nuget:?package=magic.lambda.strings&version=15.9.1                

magic.lambda.strings - Handling strings in Hyperlambda

This project contains string manipulation slots for Magic. More specifically, it gives you the following slots.

  • [strings.replace] - Replaces occurrencies 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.regex-replace] - Replaces occurrencies 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.substring] - Returns the sub-string of the specified string
  • [strings.matches] - Returns the regular expression matches found from specified source

Usage

All the above slots that requires 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

How to use [strings.replace]

This slot replaces occurrencies of a string inside a string, with some other string. The simplest version is like follows.

.foo:thomas hansen

strings.replace:x:-
   .:hansen
   .:tjobing hansen

You can also reference slots and dynamic slots for that matter, assuming your slots somehow returns strings, or something that can be converted into a string, such as the following illustrates. Notice, this code will throw an exception, since there are probably no slots called "some-slot-returning-string" in your installation.

.what:hansen
.foo:thomas hansen

strings.replace:x:-

   get-value:x:@.what

   signal:some-slot-returning-string
      arg1-to-slot:foo
      arg2-to-slot:foo

Above the first argument is "what to look for", and the second argument is "what to substitute it with". The above is a general pattern for most of these slots, where the node arguments supplied to the slot will be evaluated as a lambda object, before the arguments are consumed, allowing you to use arguments that are the result of invoking other slots as arguments to your original outer most slot.

How to use [strings.replace-not-of]

This slot will replace every single character in your original string, that cannot be found in its first argument, with the value of its second argument. This slot is useful if you want to remove all characters that cannot be found in another character set, such as the following illustrates.

strings.replace-not-of:foo bar1howdy
   .:abcdefghijklmnopqrstuvwxyz
   .:-

The above will result in the following result

strings.replace-not-of:foo-bar-howdy

How to use [strings.capitalize]

Turns the first character of your string into a CAPS character.

strings.capitalize:thomas

/*
 * Resulting in "Thomas" after invocation.
 */

How to use [strings.concat]

Concatenates a list of strings into one string. Similar to [strings.join], except it doesn't take a separating character.

.bar:Bar
strings.concat
   .:Thomas
   .:" "
   .:Hansen
   .:" "
   .:Foo
   .:" "
   get-value:x:@.bar

/*
 * Resulting in "Thomas Hansen Foo Bar" after invocation.
 */

How to use [strings.contains]

Returns true if the specified string contains some sequence of characters.

// Returns true
strings.contains:Thomas Hansen Is Cool
   .:Hansen

How to use [strings.ends-with]

Returns true if the specified string ends with some sequence of characters.

// Returns true
strings.ends-with:Thomas Hansen Is Cool
   .:Cool

// Returns false
strings.ends-with:Thomas Hansen Is Coolio
   .:Cool

How to use [strings.starts-with]

Returns true if the specified string starts with some sequence of characters.

// Returns true
strings.ends-with:Thomas Hansen Is Cool
   .:Thomas

// Returns false
strings.ends-with:Thomas Hansen Is Cool
   .:Hansen

How to use [strings.join]

Similar to [strings.concat], except it also takes an optional separating character, allowing you to concatenate a bunch of strings, and making sure each original string is separated by some sequence of strings.

.src
   .:foo
   .:bar
strings.join:x:@.src/*
   .:,

/*
 * Results in "foo,bar"
 */

How to use [strings.length]

Returns the length of a string as an integer number.

// Returns 6
strings.length:thomas

How to use [strings.regex-replace]

Replaces matches of the given regular expression with some static sequence of characters.

// Results in "FOO bar hansen"
strings.regex-replace:foo bar hansen
   .:fo+
   .:FOO

The first argument is what regular expression to match, the second argument is what to replace all matches with.

How to use [strings.split]

Splits a string into multiple strings, where a sequence of characters can be found, removing the original sequence of characters from the resulting node set.

.foo:some input string
strings.split:x:-
   .:' '

The above will result in the following result.

.foo:some input string
strings.split:x:-
   .:some
   .:input
   .:string

How to use [strings.to-lower]

Turns every single character in your input string into a lowercase character.

strings.to-lower:Thomas Hansen Is Cool

// Results in "thomas hansen is cool"

How to use [strings.to-upper]

Turns every single character in your input string into a UPPER case character.

strings.to-upper:Thomas Hansen Is Cool

// Results in "THOMAS HANSEN IS COOL"

How to use [strings.trim], [strings.trim-start], [strings.trim-end]

Trims a string, either both sides, only the start of it, or only the end of it, for occurrencies of characters found in the sequence of characters provided as its argument.

strings.trim:09thomas12
   .:1234567890

// Results in "thomas"

How to use [strings.url-encode]

URL encodes a string. Example can be found below.

strings.url-encode:thomas@servergardens.com

Resulting in the following after execution.

strings.url-encode:thomas%40servergardens.com

How to use [strings.url-decode]

URL decodes a string, the opposite of [strings.url-encode]. Example can be found below.

strings.url-encode:thomas@servergardens.com
strings.url-decode:x:-

Resulting in the following after execution.

strings.url-encode:thomas%40servergardens.com
strings.url-decode:thomas@servergardens.com

How to use [strings.substring]

Returns a substring of the specified string.

.input:Foo Bar Howdy World
strings.substring:x:-
   .:5
   .:7

The above will result in the following.

strings.substring:ar Howd

Notice, the second argument is the number of characters to return and not the offset into the string of where to stop returning. In such a regard, it works the same way as the C# Substring method.

How to use [strings.matches]

Returns all regular expression matches from specified source string.

.input:Foo Bar Howdy World {match1} and {match2} and that was it
strings.matches:x:-
   .:"\\{.+?\\}"

The above will result in the following.

strings.matches
   .:{match1}
   .:{match2}

Notice, the second argument is the number of characters to return and not the offset into the string of where to stop returning. In such a regard, it works the same way as the C# Substring method.

Project website for magic.lambda.strings

The source code for this repository can be found at github.com/polterguy/magic.lambda.strings, and you can provide feedback, provide bug reports, etc at the same place.

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on magic.lambda.strings:

Package Downloads
magic.library

Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
17.3.3 344 2/8/2024
17.2.0 224 1/22/2024
17.1.7 208 1/12/2024
17.1.6 150 1/11/2024
17.1.5 181 1/5/2024
17.0.1 216 1/1/2024
17.0.0 379 12/14/2023
16.11.5 355 11/12/2023
16.9.0 365 10/9/2023
16.7.0 583 7/11/2023
16.4.2 355 7/3/2023
16.4.1 270 7/2/2023
16.4.0 436 6/22/2023
16.3.1 392 6/7/2023
16.3.0 378 5/28/2023
16.1.9 681 4/30/2023
15.10.11 490 4/13/2023
15.9.1 666 3/27/2023
15.9.0 525 3/24/2023
15.8.2 566 3/20/2023
15.7.0 447 3/6/2023
15.5.13 1,051 2/13/2023
15.5.9 491 2/11/2023
15.5.0 896 1/28/2023
15.2.0 723 1/18/2023
15.1.0 1,202 12/28/2022
14.5.7 758 12/13/2022
14.5.5 866 12/6/2022
14.5.1 694 11/23/2022
14.5.0 654 11/18/2022
14.4.5 744 10/22/2022
14.4.1 818 10/22/2022
14.4.0 712 10/17/2022
14.3.1 1,318 9/12/2022
14.3.0 684 9/10/2022
14.1.3 963 8/7/2022
14.1.2 730 8/7/2022
14.1.1 727 8/7/2022
14.0.14 733 7/26/2022
14.0.12 732 7/24/2022
14.0.11 655 7/23/2022
14.0.10 687 7/23/2022
14.0.9 702 7/23/2022
14.0.8 771 7/17/2022
14.0.5 834 7/11/2022
14.0.4 846 7/6/2022
14.0.3 757 7/2/2022
14.0.2 692 7/2/2022
14.0.0 909 6/25/2022
13.4.0 2,139 5/31/2022
13.3.4 1,481 5/9/2022
13.3.0 996 5/1/2022
13.2.0 1,217 4/21/2022
13.1.0 1,090 4/7/2022
13.0.0 750 4/5/2022
11.0.5 1,466 3/2/2022
11.0.4 824 2/22/2022
11.0.3 797 2/9/2022
11.0.2 833 2/6/2022
11.0.1 803 2/5/2022
10.0.21 805 1/28/2022
10.0.20 806 1/27/2022
10.0.19 772 1/23/2022
10.0.18 762 1/17/2022
10.0.15 985 12/31/2021
10.0.14 604 12/28/2021
10.0.7 1,550 12/22/2021
10.0.5 778 12/18/2021
9.9.9 1,703 11/29/2021
9.9.6 4,528 11/24/2021
9.9.3 818 11/9/2021
9.9.2 655 11/4/2021
9.9.0 783 10/30/2021
9.8.9 757 10/29/2021
9.8.7 687 10/27/2021
9.8.6 670 10/27/2021
9.8.5 706 10/26/2021
9.8.0 1,434 10/20/2021
9.7.9 653 10/19/2021
9.7.5 1,530 10/14/2021
9.7.0 913 10/9/2021
9.6.6 1,257 8/14/2021
9.3.5 4,613 6/18/2021
9.2.0 2,393 5/26/2021
9.1.4 1,313 4/21/2021
9.1.0 1,115 4/14/2021
9.0.0 930 4/5/2021
8.9.9 1,079 3/30/2021
8.9.3 1,620 3/19/2021
8.9.2 1,071 1/29/2021
8.9.1 1,110 1/24/2021
8.9.0 1,171 1/22/2021
8.6.9 2,965 11/8/2020
8.6.7 1,233 11/4/2020
8.6.6 1,302 11/2/2020
8.6.0 4,060 10/28/2020
8.5.0 1,933 10/23/2020
8.4.1 4,861 10/15/2020
8.4.0 1,328 10/13/2020
8.3.1 2,698 10/5/2020
8.3.0 1,269 10/3/2020
8.2.2 2,046 9/26/2020
8.2.1 1,343 9/25/2020
8.2.0 1,371 9/25/2020
8.1.17 6,755 9/13/2020
8.1.16 643 9/13/2020
8.1.15 1,928 9/12/2020
8.1.11 2,556 9/11/2020
8.1.10 1,307 9/6/2020
8.1.9 1,369 9/3/2020
8.1.8 1,326 9/2/2020
8.1.7 1,223 8/28/2020
8.1.4 1,253 8/25/2020
8.1.3 1,309 8/18/2020
8.1.2 1,247 8/16/2020
8.1.1 1,328 8/15/2020
8.1.0 646 8/15/2020
8.0.1 2,771 8/7/2020
8.0.0 1,286 8/7/2020
7.0.1 1,458 6/28/2020
7.0.0 1,391 6/28/2020
5.0.0 7,540 2/25/2020
4.0.4 7,962 1/27/2020
4.0.3 1,292 1/27/2020
4.0.2 1,471 1/16/2020
4.0.1 1,425 1/11/2020
4.0.0 1,389 1/5/2020
3.1.0 6,344 11/10/2019
3.0.0 3,941 10/23/2019
2.0.2 7,801 10/16/2019
2.0.1 1,229 10/15/2019
2.0.0 1,637 10/13/2019
1.1.8 1,409 10/11/2019
1.1.7 1,327 10/10/2019
1.1.6 626 10/9/2019
1.1.5 633 10/6/2019
1.1.4 611 10/6/2019
1.1.3 639 10/6/2019
1.1.2 642 10/5/2019
1.0.0 681 9/26/2019