mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-05-15 17:06:59 +02:00
Updates to Utilities
This commit is contained in:
parent
6cb61ca63e
commit
5508c749ce
13 changed files with 417 additions and 13 deletions
|
@ -96,18 +96,30 @@ namespace Utilities
|
|||
}
|
||||
|
||||
public static List<string> SplitIgnoreQuotedSeparators(string str, char separator)
|
||||
{
|
||||
return SplitIgnoreQuotedSeparators(str, separator, StringSplitOptions.None);
|
||||
}
|
||||
|
||||
public static List<string> SplitIgnoreQuotedSeparators(string str, char separator, StringSplitOptions options)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
int nextEntryIndex = 0;
|
||||
int separatorIndex = IndexOfUnquotedChar(str, separator);
|
||||
while (separatorIndex >= nextEntryIndex)
|
||||
{
|
||||
result.Add(str.Substring(nextEntryIndex, separatorIndex - nextEntryIndex));
|
||||
|
||||
string entry = str.Substring(nextEntryIndex, separatorIndex - nextEntryIndex);
|
||||
if (options != StringSplitOptions.RemoveEmptyEntries || entry != String.Empty)
|
||||
{
|
||||
result.Add(entry);
|
||||
}
|
||||
nextEntryIndex = separatorIndex + 1;
|
||||
separatorIndex = IndexOfUnquotedChar(str, separator, nextEntryIndex);
|
||||
}
|
||||
result.Add(str.Substring(nextEntryIndex));
|
||||
string lastEntry = str.Substring(nextEntryIndex);
|
||||
if (options != StringSplitOptions.RemoveEmptyEntries || lastEntry != String.Empty)
|
||||
{
|
||||
result.Add(lastEntry);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue