$re = '/(?:```.*\s+|\s+```)/';
$str = '```html
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BPA vs. RPA</title>
<style>
table {
width: 80%;
margin: 20px auto;
border-collapse: collapse;
font-family: Arial, sans-serif;
background-color: #f9f9f9;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #ff785b;
color: white;
text-transform: uppercase;
}
tr:hover {
background-color: #f1f1f1;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<table>
<tr>
<th>Aspect</th>
<th>Manual Collection</th>
<th>API-Based Collection</th>
</tr>
<tr>
<td>Speed</td>
<td>Slow</td>
<td>Fast</td>
</tr>
<tr>
<td>Accuracy</td>
<td>3-4% error rate</td>
<td>Very accurate</td>
</tr>
<tr>
<td>Data Volume</td>
<td>Limited</td>
<td>High capacity</td>
</tr>
<tr>
<td>Cost</td>
<td>Higher (labor)</td>
<td>Lower long-term</td>
</tr>
<tr>
<td>Consistency</td>
<td>Variable</td>
<td>Uniform</td>
</tr>
</table>
</body>
```';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php