$re = '/((?:\\\\u[\da-fA-F]{4}){2})/';
$str = 'Hi, Jax\\ud83d\\ude1b\\ud83d\\ude44! can we go for a coffee?
Now, the emoji are in UTF16(I think). I need to extract the \'\\ud83d\\ude1b\\ud83d\\ude44\' and give a space between each pair, something like this.
Hi, Jax\\ud83d\\ude1b \\ud83d\\ude44! can we go for a coffee?
How can I achieve this in PHP?
More Examples as I would need:-
Hi, Jax\\ud83d\\ude1b \\ud83d\\ude44! can we go for\\ud83d\\ude1b \\ud83d\\ude44 a coffee?
So What needed to be done:-
User may or may not leave any space after any normal word and just type a emoji. I mean, Jax\\ud83d\\ude1b and Jax \\ud83d\\ude1b.';
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