$re = '/^(\w+) (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})\@\d+ ((?:myself,)?[\w?]+) ([\w-]+) ([\d]+) ([\d]+) ([\d]+) ([\w]+) ?([ \-\d]+)? ?(\[[\d]+-(?:>|<)-[\w]+\])?/m';
$str = '6535e1a5ba67e01527275299ba4328f26872e3d0 10.229.170.172:7000 slave 81bb21169500bf77638103c9c09583101e475639 0 1597310146695 7 connected
d2b0b248493fcfbf8522e9546f1057706a18187a 10.229.170.171:7000 slave 2236a749ebf3a8bce1f6ac1ffc3100b28db46604 0 1597310148732 11 connected
db50d92a23cee951eff8c5d9f64888a9d1a00a13 10.230.140.208:7000 slave f9d94b7ee9cf684199a1b713ae3f37a1de820f52 0 1597310149249 8 connected
ce7410975901a74c1475c449fd8216cd22168865 10.230.140.208:7001 myself,master - 0 0 10 connected 13505-16383 [13505->-2236a749ebf3a8bce1f6ac1ffc3100b28db46604]
bf6f4d7f5330fe134a575bcf7e36fd012b4a5cf4 10.230.140.209:7001 master - 0 1597310145681 5 connected 3277-6553
518f3da0ab884b2808e278e7d885d77fa7b70abc 10.230.140.210:7000 slave bf6f4d7f5330fe134a575bcf7e36fd012b4a5cf4 0 1597310143665 5 connected
f9d94b7ee9cf684199a1b713ae3f37a1de820f52 10.230.140.209:7000 master - 0 1597310144673 8 connected 50-3276
d2037c152950b5927795d739d1f60d9230bc5243 10.229.170.172:7001 slave ce7410975901a74c1475c449fd8216cd22168865 0 1597310148608 10 connected
2236a749ebf3a8bce1f6ac1ffc3100b28db46604 10.230.140.210:7001 master - 0 1597310141662 11 connected 0-49 6554-9880 13108-13220
81bb21169500bf77638103c9c09583101e475639 10.229.170.171:7001 master - 0 1597310139156 6 connected 9881-13107
6535e1a5ba67e01527275299ba4328f26872e3d0 10.229.170.172:7000 slave 81bb21169500bf77638103c9c09583101e475639 0 1597310142666 7 connected
d2b0b248493fcfbf8522e9546f1057706a18187a 10.229.170.171:7000 slave 2236a749ebf3a8bce1f6ac1ffc3100b28db46604 0 1597310143164 11 connected
db50d92a23cee951eff8c5d9f64888a9d1a00a13 10.230.140.208:7000 slave f9d94b7ee9cf684199a1b713ae3f37a1de820f52 0 1597310141662 8 connected
ce7410975901a74c1475c449fd8216cd22168865 10.230.140.208:7001 myself,master - 0 0 10 connected 13221-16383 [13221->-2236a749ebf3a8bce1f6ac1ffc3100b28db46604]
bf6f4d7f5330fe134a575bcf7e36fd012b4a5cf4 10.230.140.209:7001 master - 0 1597310140659 5 connected 3277-6553
518f3da0ab884b2808e278e7d885d77fa7b70abc 10.230.140.210:7000 slave bf6f4d7f5330fe134a575bcf7e36fd012b4a5cf4 0 1597310143665 5 connected
f9d94b7ee9cf684199a1b713ae3f37a1de820f52 10.230.140.209:7000 master - 0 1597310144673 8 connected 50-3276
d2037c152950b5927795d739d1f60d9230bc5243 10.229.170.172:7001 slave ce7410975901a74c1475c449fd8216cd22168865 1597310144167 1597310136651 10 connected
ce7410975901a74c1475c449fd8216cd22168865 10.230.140.208:7001 myself,master - 0 0 12 connected 0-49 6554-6842 15254-16383 [6843-<-2236a749ebf3a8bce1f6ac1ffc3100b28db46604]
bf6f4d7f5330fe134a575bcf7e36fd012b4a5cf4 10.230.140.209:7001 master - 0 1597319746589 5 connected 3277-6553
518f3da0ab884b2808e278e7d885d77fa7b70abc 10.230.140.210:7000 slave bf6f4d7f5330fe134a575bcf7e36fd012b4a5cf4 0 1597319749595 5 connected
f9d94b7ee9cf684199a1b713ae3f37a1de820f52 10.230.140.209:7000 master - 0 1597319746089 8 connected 50-3276
d2037c152950b5927795d739d1f60d9230bc5243 10.229.170.172:7001 slave ce7410975901a74c1475c449fd8216cd22168865 0 1597319747590 12 connected
2114d318b6bff84367748b0af1480414625db481 10.225.129.237:7000@17000 slave 17a137f8c8ab3886abf9ef756a9e46ce00b3db46 0 1597323334000 8 connected
f7b8bc2f99e217a9aa33165771d63ac00130bf06 10.225.129.236:7000@17000 slave 29accc30f88be4c5a1b5c316ef4a07db11e773ca 0 1597323335000 1 connected
29accc30f88be4c5a1b5c316ef4a07db11e773ca 10.225.129.235:7000@17000 myself,master - 0 1597323336000 1 connected 0-2730
a582a8683f6ba747ec8b1ae959c2aba2009c6fec 10.225.129.235:7001@17001 slave 9445f535348daf42827d0610b42a2f6f67c8c672 0 1597323337133 7 connected
9445f535348daf42827d0610b42a2f6f67c8c672 10.225.129.240:7001@17001 master - 0 1597323336533 7 connected 13655-16383';
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