diff --git a/ExportDXF/DrawingInfo.cs b/ExportDXF/DrawingInfo.cs index 19a7863..c05083f 100644 --- a/ExportDXF/DrawingInfo.cs +++ b/ExportDXF/DrawingInfo.cs @@ -1,10 +1,11 @@ -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace ExportDXF { public class DrawingInfo { private static Regex drawingFormatRegex = new Regex(@"(?[345]\d{3}(-\d+\w{1,2})?)\s?(?[ABEP]\d+(-?(\d+[A-Z]?))?)", RegexOptions.IgnoreCase); + private static Regex equipmentOnlyRegex = new Regex(@"^(?[345]\d{3}(-\d+\w{1,2})?)\b", RegexOptions.IgnoreCase); public string EquipmentNo { get; set; } @@ -14,6 +15,8 @@ namespace ExportDXF public override string ToString() { + if (string.IsNullOrEmpty(DrawingNo)) + return EquipmentNo ?? string.Empty; return $"{EquipmentNo} {DrawingNo}"; } @@ -35,7 +38,21 @@ namespace ExportDXF var match = drawingFormatRegex.Match(input); if (match.Success == false) + { + // Try matching just the equipment number (e.g. "5028 Prox switch bracket") + var eqMatch = equipmentOnlyRegex.Match(input); + if (eqMatch.Success) + { + return new DrawingInfo + { + EquipmentNo = eqMatch.Groups["equipmentNo"].Value, + DrawingNo = null, + Source = input + }; + } + return null; + } var dwg = new DrawingInfo(); @@ -46,4 +63,4 @@ namespace ExportDXF return dwg; } } -} \ No newline at end of file +}