Class StringExtensions
Static class that contains helper extension methods for strings.
Inheritance
Inherited Members
Namespace: Fibula.Common.Utilities.Extensions
Assembly: Fibula.Common.Utilities.dll
Syntax
public static class StringExtensions
Methods
| Improve this Doc View SourceGetEnclosedStrings(String, IEnumerable<(Char openChar, Char closeChar)>)
Retrieves the enclosed strings within a string.
Declaration
public static IEnumerable<string> GetEnclosedStrings(this string str, IEnumerable<(char openChar, char closeChar)> openClosePairs)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The string from which to retrieve the enclosured strings. |
System.Collections.Generic.IEnumerable<System.ValueTuple<System.Char, System.Char>> | openClosePairs | A collection of open and close characters between which to look for enclosed strings. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A collection of enclosed string contained in the string. |
SplitByToken(String, Char)
Splits a string using the given token, but preserving any quoted strings.
Declaration
public static IEnumerable<string> SplitByToken(this string str, char token = ' ')
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The string to split. |
System.Char | token | Optional. The token to split by. Defaults to Fibula.Common.Utilities.Extensions.StringExtensions.Space. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A collection of strings resulting from the split. |
TrimEnclosures(String, IEnumerable<(Char openChar, Char closeChar)>)
Trims the open and close chars from the string.
Declaration
public static string TrimEnclosures(this string inputStr, IEnumerable<(char openChar, char closeChar)> openClosePairs)
Parameters
Type | Name | Description |
---|---|---|
System.String | inputStr | The string to trim the pairs from. |
System.Collections.Generic.IEnumerable<System.ValueTuple<System.Char, System.Char>> | openClosePairs | The collection of open and close pairs. |
Returns
Type | Description |
---|---|
System.String | The resulting string after trim. |
TrimStartArticles(String)
Trims the articles "a" and "an" out of the given string.
Declaration
public static string TrimStartArticles(this string fromString)
Parameters
Type | Name | Description |
---|---|---|
System.String | fromString | The string to trim the articles from. |
Returns
Type | Description |
---|---|
System.String | The resulting stream. |