StringExtractor 2.0.0
dotnet add package StringExtractor --version 2.0.0
NuGet\Install-Package StringExtractor -Version 2.0.0
<PackageReference Include="StringExtractor" Version="2.0.0" />
<PackageVersion Include="StringExtractor" Version="2.0.0" />
<PackageReference Include="StringExtractor" />
paket add StringExtractor --version 2.0.0
#r "nuget: StringExtractor, 2.0.0"
#:package StringExtractor@2.0.0
#addin nuget:?package=StringExtractor&version=2.0.0
#tool nuget:?package=StringExtractor&version=2.0.0
StringExtractor
You can extract a part of string from long string.
using StringExtractors;
var longString = "It takes three hours.";
// result is "three".
var result = StringExtractor.Extract(longString, "takes ", " hours.").Value;
If you want to extract a string which is located at head or end of long string, omit leftString or rightString.
using StringExtractors;
var longString = "One Two Three";
// leftString is omitted. result1 is "One".
var result1 = StringExtractor.Extract(longString, rightString: " Two").Value;
// rightString is omitted. result2 is "Three".
var result2 = StringExtractor.Extract(longString, leftString: "Two ").Value;
For more complicated case, use StringExtractorParameters.
using StringExtractors;
var longString = "I'm Jack. I'm Tyler."
// Search leftString from the end of longString. So, result is "Tyler".
var leftString = new LeftString(
"I'm ",
direction: SearchDirection.Backward);
var rightString = new RightString(".");
var parameters = new StringExtractorParameters(
longString,
leftString,
rightString
);
// "Tyler"
var result = StringExtractor.Extract(parameters).Value;
using StringExtractors;
var longString = "I'm George Washington. I'm Abraham Lincoln."
var leftString = new LeftString("I'm ");
var rightString = new RightString("Lincoln.");
// Search rightString first. So, result is "Abraham".
var parameters = new StringExtractorParameters(
longString,
leftString,
rightString,
searchOrder: SearchOrder.RightFirst
);
// "Abraham"
var result = StringExtractor.Extract(parameters).Value;
Extract method of StringExtractor returns ExtractionResult. ExtractionResult has two properties, Value and IndexCollection. Value is extracted string. IndexCollection has three properties, Left (index of LeftString in source. Source is longString in above examples), Right (index of RightString in source.), Head (index of extracted string in source.).
StringExtractorParameters has five arguments. Source is a string which contains extract target. LeftString is a string locates at left side of extract target. Omit this if extract target locates at head of source. RightString is a string locates at right side of extract target. Omit this if extract target locates at end of source. SearchOrder specifies which of LeftString or RightString is searched first. StartIndex is an index of start searching.
LeftString and RightString have four arguments. Value is a string of Left/RightString. Skip ignores same string with value for specified times. Use this when same string with value appears multiple times is source. Direction is direction of searching value in source. StringComparison is culture, case, and sort rules for string comparison.
If you want to use regular expression, pass RegexStringType to Left/RightString instead of above four arguments. RegexStringType has two properties, Pattern and Options. Pattern is pattern of regular expression. (Same role with value of above arguments.) Options has same constants with RegexOptions in System.Text.RegularExpressions, except that LeftToRight is appended.
| Product | Versions 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. net9.0 was computed. 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 was computed. 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 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. |
-
.NETStandard 2.0
- No dependencies.
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 |
|---|---|---|
| 2.0.0 | 292 | 9/8/2024 |
| 2.0.0-alpha | 330 | 11/26/2023 |
| 1.0.1 | 278 | 11/14/2023 |
| 1.0.0 | 214 | 10/10/2023 |
Added many features.