mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Style] Attempt to fix CMP line parsing again
This commit is contained in:
@@ -543,12 +543,13 @@ namespace SabreTools.Library.Tools
|
|||||||
/// <remarks>Uses code from http://stackoverflow.com/questions/554013/regular-expression-to-split-on-spaces-unless-in-quotes</remarks>
|
/// <remarks>Uses code from http://stackoverflow.com/questions/554013/regular-expression-to-split-on-spaces-unless-in-quotes</remarks>
|
||||||
public static string[] SplitLineAsCMP(string s)
|
public static string[] SplitLineAsCMP(string s)
|
||||||
{
|
{
|
||||||
// Preprocess the string
|
// Get the opening and closing brace locations
|
||||||
|
int openParenLoc = s.IndexOf('(');
|
||||||
|
int closeParenLoc = s.LastIndexOf(')');
|
||||||
|
|
||||||
|
// Now remove anything outside of those braces, including the braces
|
||||||
|
s = s.Substring(openParenLoc + 1, closeParenLoc - openParenLoc - 1);
|
||||||
s = s.Trim();
|
s = s.Trim();
|
||||||
s = Regex.Replace(s, @"^\S* \(", ""); // Remove item identifier and opening brace
|
|
||||||
s = Regex.Replace(s, @"\)\s*#.*$", ""); // Remove trailing comments
|
|
||||||
s = s.TrimEnd(')'); // Remove closing brace
|
|
||||||
s = s.Trim(); // Remove leading and trailing whitespace
|
|
||||||
|
|
||||||
// Now we get each string, divided up as cleanly as possible
|
// Now we get each string, divided up as cleanly as possible
|
||||||
string[] matches = Regex
|
string[] matches = Regex
|
||||||
|
|||||||
Reference in New Issue
Block a user