/// <summary> /// Split a string by line breaks. /// </summary> /// <param name="source"> /// The string to split. /// </param> /// <returns> /// The split strings. /// </returns> private static IEnumerable <string> SplitByLineBreaks(string source) { return(LineRegex .Matches(source) .Cast <Match>() .Select(x => x.Value)); }
public IniPropertyData(string existingText) : base(IniLineType.Property, existingText) { var matches = LineRegex.Matches(existingText); Key = matches[0].Groups[1].Value.Trim(); Value = matches[0].Groups[2].Value.Trim(); }
private IniCommentData(string textOrLine, bool isLine) : base(IniLineType.Comment, isLine ? textOrLine : null) { if (string.IsNullOrWhiteSpace(textOrLine)) { throw new System.ArgumentException("message", nameof(textOrLine)); } if (isLine) { var matches = LineRegex.Matches(textOrLine); Text = matches[0].Groups[1].Value.Trim(); } else { Text = textOrLine; } }
private IniSectionData(string nameOrLine, bool isLine) : base(IniLineType.SectionHeader, isLine ? nameOrLine : null) { if (string.IsNullOrWhiteSpace(nameOrLine)) { throw new ArgumentException("message", nameof(nameOrLine)); } if (isLine) { var matches = LineRegex.Matches(nameOrLine); Name = matches[0].Groups[1].Value; } else { Name = nameOrLine; } AddLine(this); }