<?php
$string = "Hello, my name is http://www.audio.com/1234.mp3/. Today is https://radio.org/weather.wav";
var_export(
preg_split(
'#\s*(https?://\S+(?<![,.]))\s*#',
$string,
flags: PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
)
);
- Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- array (
0 => 'Hello, my name is',
1 => 'http://www.audio.com/1234.mp3/',
2 => '. Today is',
3 => 'https://radio.org/weather.wav',
)
preferences:
87.63 ms | 406 KiB | 5 Q