I have below string. This string having data (@[ID:username__FULLNAME]) of three users mentioned. I want to extract them. I have tried below code but not getting desired results.
ID is integer type
username and FULLNAME may contain numbers, letter and all kind of special chars.
$t = 'Hi @[4232:mark__MΛRK ATTLEY] how are you ?
Hi @[4232:ryan__RYΛN вυηту] how are you ?
Hi @[4232:david__DΛVID शाहिद ] how are you ?
';
My PHP CODE:
$pattern = "|(?:(@\[[0-9]+:[\s\S(?!\])]+\]*))|";
preg_match_all($pattern, $string, $mentionList, PREG_PATTERN_ORDER);
print_r($mentionList);
Current Result:
Array
(
[0] => Array
(
[0] => @[4232:mark__MΛRK ATTLEY] how are you ?
Hi @[4232:ryan__RYΛN вυηту] how are you ?
Hi @[4232:david__DΛVID शाहिद] how are you ?
)
[1] => Array
(
[0] => @[4232:mark__MΛRK ATTLEY] how are you ?
Hi @[4232:ryan__RYΛN вυηту] how are you ?
Hi @[4232:david__DΛVID शाहिद] how are you ?
)
)
Expected Result:
Array
(
[0] => Array
(
[0] => @[4232:mark__MΛRK ATTLEY]
[1] => @[4232:ryan__RYΛN вυηту]
[2] => @[4232:david__DΛVID शाहिद ]
)
)
Can someone help me getting the desired results?
Thanks.