fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var str = "The DELETE statement conflicted with the REFERENCE constraint \"FK_dbo.MyApprovals_dbo.My_ApproverMyId\". The conflict occurred in database \"DatabaseDev\", table \"dbo.DatabaseTable\", column 'ApproverPositionId'.\r\nThe statement has been terminated.";
  12. var m = Regex.Match(str, @"(?s)(?<delete>[A-Z]+)\s+statement.*?,\s+table\s+""\w+\.(?<table>[^""]+)");
  13. if (m.Success) {
  14. Console.WriteLine(m.Groups["delete"].Value);
  15. Console.WriteLine(m.Groups["table"].Value);
  16. }
  17. }
  18. }
Success #stdin #stdout 0.13s 24456KB
stdin
Standard input is empty
stdout
DELETE
DatabaseTable