using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"((?:\\u[\da-fA-F]{4}){2})";
string input = @"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.";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx