TedToolkit.InterpolatedParser
2026.4.8
dotnet add package TedToolkit.InterpolatedParser --version 2026.4.8
NuGet\Install-Package TedToolkit.InterpolatedParser -Version 2026.4.8
<PackageReference Include="TedToolkit.InterpolatedParser" Version="2026.4.8" />
<PackageVersion Include="TedToolkit.InterpolatedParser" Version="2026.4.8" />
<PackageReference Include="TedToolkit.InterpolatedParser" />
paket add TedToolkit.InterpolatedParser --version 2026.4.8
#r "nuget: TedToolkit.InterpolatedParser, 2026.4.8"
#:package TedToolkit.InterpolatedParser@2026.4.8
#addin nuget:?package=TedToolkit.InterpolatedParser&version=2026.4.8
#tool nuget:?package=TedToolkit.InterpolatedParser&version=2026.4.8
TedToolkit.InterpolatedParser
A .NET library that parses strings using C# interpolated string syntax — extract typed values from text by writing the pattern as an interpolated string.
Installation
dotnet add package TedToolkit.InterpolatedParser
Quick Start
using TedToolkit.InterpolatedParser;
var name = "";
"I am Ted!".Parse($"I am {name}!");
// name == "Ted"
That's it. Write the interpolated string as if you were formatting the output, and the library runs the process in reverse to extract the values.
Usage
Parsing Strings
var name = "";
// Value at the end
"I am Ted".Parse($"I am {name}");
// Value at the start
"Ted is me!".Parse($"{name} is me!");
// Value in the middle
"Hello Ted, welcome!".Parse($"Hello {name}, welcome!");
Parsing Numbers
var age = 0;
"I am 18 years old!".Parse($"I am {age} years old!");
// age == 18
All primitive numeric types are supported: int, long, double, float, decimal, byte, short, uint, ulong, ushort, sbyte.
On .NET 7+, any type implementing INumber<T> or IParsable<T> works automatically.
Parsing Arrays and Lists
// Default separator: comma
string[] names = [];
"There are A,B,C".Parse($"There are {names}");
// names == ["A", "B", "C"]
// Custom separator
string[] names = [];
"There are A;B;C.".Parse($"There are {names:;}.");
// names == ["A", "B", "C"]
// Works with typed arrays too
int[] numbers = [];
"Values: 1,2,3".Parse($"Values: {numbers}");
List<T> is also supported with the same syntax.
Parsing Enums
MyEnum value = default;
"Status: Active".Parse($"Status: {value}");
// Enum arrays with custom separator
MyEnum[] values = [];
"Items: A;B;C.".Parse($"Items: {values:;}.");
Regex-Based Parsing
For patterns with repetition or flexible matching, use regex syntax:
var a = "";
var b = "";
"I am sooooo cool!!Thanks!".ParseRegex($"I am so+ {a}!+{b}");
// a == "cool", b == "Thanks!"
Error Handling
// Parse() throws on failure; TryParse() does not
var result = "some input".TryParse($"pattern {value}");
if (result.Type == ParseResultType.SUCCEED)
{
// value was populated
}
// Regex variants
var result = "input".TryParseRegex($"pattern+ {value}");
ParseResult contains:
Type—SUCCEED,FAILED_TO_INDEX, orFAILED_TO_PARSEMessage— error details on failureResults— sub-results for composite parsers
Custom Parsers
Register your own parser for any type:
public class PointParser : IInterpolatedParser<Point>
{
public ParseResult Parse(ReadOnlySpan<char> input, string format, ref Point result, bool noExceptions)
{
// your parsing logic
return ParseResult.Succeed;
}
}
InterpolatedParserSettings.AddParser(new PointParser());
Or register a parser creator for families of types:
public class MyCreator : IInterpolatedParserCreator
{
public bool CanCreate(Type type) => /* check type */;
public IInterpolatedParser Create(Type type) => /* create parser */;
}
InterpolatedParserSettings.AddParserCreator(new MyCreator());
Supported Frameworks
| Framework | Versions |
|---|---|
| .NET | 6.0, 7.0, 8.0, 9.0, 10.0 |
| .NET Framework | 4.7.2, 4.8 |
| .NET Standard | 2.0, 2.1 |
License
LGPL-3.0 — see COPYING and COPYING.LESSER.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. 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. |
-
.NETFramework 4.7.2
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- TedToolkit.Localizations (>= 2026.2.1.2)
-
.NETFramework 4.8
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- TedToolkit.Localizations (>= 2026.2.1.2)
-
.NETStandard 2.0
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- TedToolkit.Localizations (>= 2026.2.1.2)
-
.NETStandard 2.1
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- TedToolkit.Localizations (>= 2026.2.1.2)
-
net10.0
- TedToolkit.Localizations (>= 2026.2.1.2)
-
net6.0
- TedToolkit.Localizations (>= 2026.2.1.2)
-
net7.0
- TedToolkit.Localizations (>= 2026.2.1.2)
-
net8.0
- TedToolkit.Localizations (>= 2026.2.1.2)
-
net9.0
- TedToolkit.Localizations (>= 2026.2.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.4.8 | 73 | 4/8/2026 |
| 2026.2.3.2 | 102 | 2/3/2026 |
| 2025.12.23.1 | 196 | 12/23/2025 |
| 2025.12.23 | 196 | 12/23/2025 |
| 2025.12.17 | 288 | 12/17/2025 |
| 2025.12.12.2 | 141 | 12/12/2025 |
| 2025.12.12.1 | 139 | 12/12/2025 |
| 2025.12.12 | 153 | 12/12/2025 |
| 2025.12.9 | 457 | 12/9/2025 |
| 2025.11.25 | 198 | 11/25/2025 |
| 2025.11.24.3 | 200 | 11/24/2025 |
| 2025.11.24.2 | 197 | 11/24/2025 |
| 2025.11.24.1 | 198 | 11/24/2025 |
| 2025.11.24 | 197 | 11/24/2025 |
| 2025.11.21 | 415 | 11/21/2025 |
| 2025.11.20.4 | 412 | 11/20/2025 |
| 2025.11.20.3 | 408 | 11/20/2025 |
| 2025.11.20.2 | 422 | 11/20/2025 |
| 2025.11.20.1 | 420 | 11/20/2025 |
| 2025.11.20 | 418 | 11/20/2025 |