fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string html = @"<link href=""http://www.mhpa.co.uk/reports.css"" rel=""STYLESHEET"" type=""text/css"" CHARSET=""ISO-8859-1"">
  9.  
  10. <table cellpadding=2 cellspacing=0 border=0 width=100%>
  11. <tbody>
  12. <tr>
  13. <td align=right><b>11/09/2013&nbsp;at&nbsp;09:48</b></td>
  14. </tr>
  15. </tbody>
  16. </table>
  17. <center>
  18. <table border=""1"" bordercolor=""silver"" cellpadding=""2"" cellspacing=""0"" width=""100%"">
  19. <thead>
  20. <tr>
  21. <th width=100>ETA</th>
  22. <th width=100>Ship Name</th>
  23. <th width=80>From port</th>
  24. <th width=80>To berth</th>
  25. <th width=130>Agent</th>
  26. </tr>
  27. </thead>
  28. <tbody>
  29.  
  30. <tr><td>11/09/2013 at 09:00&nbsp;</td>
  31. <td>SONANGOL KALANDULA&nbsp;</td>
  32. <td>Cabinda&nbsp;</td>
  33. <td>Valero 6&nbsp;</td>
  34. <td>Graypen&nbsp;</td>
  35. </tr>
  36.  
  37. <tr>
  38. <td>11/09/2013 at 11:45&nbsp;</td>
  39. <td>ISLE OF INISHMORE&nbsp;</td>
  40. <td>Rosslare&nbsp;</td>
  41. <td>PDFT&nbsp;</td>
  42. <td>Irish Ferries&nbsp;</td>
  43. </tr>
  44.  
  45. <tr>
  46. <td>11/09/2013 at 12:00&nbsp;</td>
  47. <td>BRO DEVELOPER&nbsp;</td>
  48. <td>Avonmouth&nbsp;</td>
  49. <td>Valero 8&nbsp;</td>
  50. <td>GAC&nbsp;</td>
  51. </tr>
  52.  
  53. <tr>
  54. <td>11/09/2013 at 14:00&nbsp;</td>
  55. <td>WELSH PIPER&nbsp;</td>
  56. <td>Sea&nbsp;</td>
  57. <td>POP No 1&nbsp;</td>
  58. <td>Tarmac Marine Dredging Ltd&nbsp;</td>
  59. </tr>
  60.  
  61. <tr>
  62. <td>11/09/2013 at 22:00&nbsp;</td>
  63. <td>PATRICIA&nbsp;</td>
  64. <td>Le Havre&nbsp;</td>
  65. <td>Murco 1&nbsp;</td>
  66. <td>GAC&nbsp;</td>
  67. </tr>
  68.  
  69. <tr>
  70. <td>12/09/2013 at 05:00&nbsp;</td>
  71. <td>BRO DESIGNER&nbsp;</td>
  72. <td>Plymouth&nbsp;</td>
  73. <td>Murco 2&nbsp;</td>
  74. <td>Graypen&nbsp;</td>
  75. </tr>
  76.  
  77. <tr>
  78. <td>12/09/2013 at 06:00&nbsp;</td>
  79. <td>BASTOGNE&nbsp;</td>
  80. <td>Mongstad&nbsp;</td>
  81. <td>Valero 3&nbsp;</td>
  82. <td>Denholm Wilhelmsen Ltd&nbsp;</td>
  83. </tr>
  84.  
  85. <tr>
  86. <td>12/09/2013 at 06:00&nbsp;</td>
  87. <td>MINERVA GRACE&nbsp;</td>
  88. <td>Ras Lanuf&nbsp;</td>
  89. <td>Valero 1&nbsp;</td>
  90. <td>Graypen&nbsp;</td>
  91. </tr>
  92.  
  93. <tr>
  94. <td>12/09/2013 at 06:00&nbsp;</td>
  95. <td>LEANDER&nbsp;</td>
  96. <td>Dublin &nbsp;</td>
  97. <td>Murco 2&nbsp;</td>
  98. <td>Graypen&nbsp;</td>
  99. </tr>
  100.  
  101. <tr>
  102. <td>12/09/2013 at 07:00&nbsp;</td>
  103. <td>THUN GLOBE&nbsp;</td>
  104. <td>Cardiff&nbsp;</td>
  105. <td>Valero 7&nbsp;</td>
  106. <td>GAC&nbsp;</td>
  107. </tr>
  108.  
  109. <tr>
  110. <td>13/09/2013 at 06:00&nbsp;</td>
  111. <td>THUN GENIUS&nbsp;</td>
  112. <td>Dublin &nbsp;</td>
  113. <td>Valero&nbsp;</td>
  114. <td>GAC&nbsp;</td>
  115. </tr>
  116.  
  117. <tr>
  118. <td>13/09/2013 at 11:00&nbsp;</td>
  119. <td>CAP LEON&nbsp;</td>
  120. <td>Arzew&nbsp;</td>
  121. <td>Valero 6&nbsp;</td>
  122. <td>Graypen&nbsp;</td>
  123. </tr>
  124.  
  125. <tr>
  126. <td>13/09/2013 at 19:00&nbsp;</td>
  127. <td>STOLT TEAL&nbsp;</td>
  128. <td>TBA&nbsp;</td>
  129. <td>Valero 1&nbsp;</td>
  130. <td>Cory Bros&nbsp;</td>
  131. </tr>
  132.  
  133. <tr>
  134. <td>14/09/2013 at 16:00&nbsp;</td>
  135. <td>B GAS LANRICK&nbsp;</td>
  136. <td>Antwerp&nbsp;</td>
  137. <td>Murco 3&nbsp;</td>
  138. <td>S5 Agency World&nbsp;</td>
  139. </tr>
  140.  
  141. <tr>
  142. <td>15/09/2013 at 09:00&nbsp;</td>
  143. <td>BAYAMO&nbsp;</td>
  144. <td>TBA&nbsp;</td>
  145. <td>Valero&nbsp;</td>
  146. <td>Graypen&nbsp;</td>
  147. </tr>
  148.  
  149. <tr>
  150. <td>15/09/2013 at 09:00&nbsp;</td>
  151. <td>AMADEA&nbsp;</td>
  152. <td>Cork&nbsp;</td>
  153. <td>Milford Shelf&nbsp;</td>
  154. <td>Inchcape Shipping Services&nbsp;</td>
  155. </tr>
  156.  
  157. <tr>
  158. <td>15/09/2013 at 12:00&nbsp;</td>
  159. <td>ARRAN&nbsp;</td>
  160. <td>Dublin &nbsp;</td>
  161. <td>Valero&nbsp;</td>
  162. <td>Graypen&nbsp;</td>
  163. </tr>
  164.  
  165. <tr>
  166. <td>16/09/2013 at 01:00&nbsp;</td>
  167. <td>EKFJORD&nbsp;</td>
  168. <td>Gothenburg&nbsp;</td>
  169. <td>Murco 1&nbsp;</td>
  170. <td>Cory Bros&nbsp;</td>
  171. </tr>
  172.  
  173. <tr>
  174. <td>16/09/2013 at 21:30&nbsp;</td>
  175. <td>MOZAH&nbsp;</td>
  176. <td>Ras Laffan&nbsp;</td>
  177. <td>South Hook No 1&nbsp;</td>
  178. <td>S5 Agency World&nbsp;</td>
  179. </tr>
  180.  
  181. <tr>
  182. <td>17/09/2013 at 07:00&nbsp;</td>
  183. <td>STRIDE&nbsp;</td>
  184. <td>Murmansk&nbsp;</td>
  185. <td>Valero 6&nbsp;</td>
  186. <td>Graypen&nbsp;</td>
  187. </tr>
  188. </tbody>
  189. </table>
  190. </center>";
  191.  
  192. var charSetOccurences = new Regex(@"<tr>[^<]*<td[^>]*>[^<]*</td>[^<]*<td[^>]*>(?<Ship>[^<]+)");
  193. var charSetMatches = charSetOccurences.Matches(html);
  194. foreach (Match match in charSetMatches)
  195. {
  196. string charSet = match.Groups[1].Value;
  197. Console.WriteLine(charSet);
  198. }
  199. }
  200. }
Success #stdin #stdout 0.08s 34296KB
stdin
Standard input is empty
stdout
SONANGOL KALANDULA&nbsp;
ISLE OF INISHMORE&nbsp;
BRO DEVELOPER&nbsp;
WELSH PIPER&nbsp;
PATRICIA&nbsp;
BRO DESIGNER&nbsp;
BASTOGNE&nbsp;
MINERVA GRACE&nbsp;
LEANDER&nbsp;
THUN GLOBE&nbsp;
THUN GENIUS&nbsp;
CAP LEON&nbsp;
STOLT TEAL&nbsp;
B GAS LANRICK&nbsp;
BAYAMO&nbsp;
AMADEA&nbsp;
ARRAN&nbsp;
EKFJORD&nbsp;
MOZAH&nbsp;
STRIDE&nbsp;