$re = '/^.{24}Realtime\[\d{1,3}\].*\n?/m';
$str = '2021-09-05 05:50:03.328 Realtime[248]: Uploading - realtimegauges.txt
2021-09-05 05:50:03.655 Realtime[248]: End cycle
2021-09-05 05:50:08.030 Realtime[249]: Start cycle
2021-09-05 05:50:08.030 Realtime[249]: Creating realtime.txt
2021-09-05 05:50:08.031 Realtime[249]: Processing realtime file - realtimegauges.txt
2021-09-05 05:50:08.046 Realtime[249]: Uploading - realtime.txt
2021-09-05 05:50:08.350 Realtime[249]: Uploading - realtimegauges.txt
2021-09-05 05:50:08.578 Realtime[249]: End cycle
2021-09-05 05:50:12.737 Reading live data
2021-09-05 05:50:12.759 DoCommand(CMD_GW1000_LIVEDATA): Valid response
2021-09-05 05:50:12.759 WH45 CO₂: Decoding...
2021-09-05 05:50:12.759 WH45 CO₂: temp=18.9, hum=62, pm10=1.6, pm10_24h=4.0, pm2.5=1.5, pm2.5_24h=3.2, CO₂=850, CO₂_24h=646
2021-09-05 05:50:13.030 Realtime[250]: Start cycle
2021-09-05 05:50:13.030 Realtime[250]: Creating realtime.txt
2021-09-05 05:50:13.031 Realtime[250]: Processing realtime file - realtimegauges.txt
2021-09-05 05:50:13.035 Realtime[250]: Uploading - realtime.txt
2021-09-05 05:50:13.263 Realtime[250]: Uploading - realtimegauges.txt
2021-09-05 05:50:13.503 Realtime[250]: End cycle
2021-09-05 05:50:15.232 Done creating graph data files
2021-09-05 05:50:16.020 Done uploading standard Data file
2021-09-05 05:50:17.666 GetAlCurrent: Outdoor - Waiting for lock
2021-09-05 05:50:17.666 GetAlCurrent: Outdoor - Has the lock
2021-09-05 05:50:17.666 GetAlCurrent: Outdoor - Sending GET current conditions request 1 to AL: http://192.168.59.236/v1/current_conditions ...
2021-09-05 05:50:17.774 DecodeAlCurrent: Outdoor - Found AirLink data
2021-09-05 05:50:17.774 DecodeAlCurrent: Outdoor - Using temp/hum data
2021-09-05 05:50:17.774 GetAlCurrent: Outdoor - Releasing lock
2021-09-05 05:50:18.030 Realtime[251]: Start cycle
2021-09-05 05:50:18.030 Realtime[251]: Creating realtime.txt
2021-09-05 05:50:18.032 Realtime[251]: Processing realtime file - realtimegauges.txt
2021-09-05 05:50:18.036 Realtime[251]: Uploading - realtime.txt
2021-09-05 05:50:18.303 Realtime[251]: Uploading - realtimegauges.txt
2021-09-05 05:50:18.577 Realtime[251]: End cycle
2021-09-05 05:50:20.937 Done uploading graph data files
2021-09-05 05:50:20.937 FTP[Int]: Uploading daily graph data files
2021-09-05 05:50:20.937 FTP[Int]: Done uploading daily graph data files
';
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