问题
I have some raw data like this
\u002522\u00253A\u002522https\u00253A\u00255C\u00252F\u00255C\
My intention is to remove the backslash "\" and first 7 digit of every string between \u002522https\ this. For this the output will be only https.
If there is only 7 digit like this \u002522\ the output will be empty.
My final intention is to put every result in a array which is formatted for the above raw data like this
Array
(
[0] =>
[1] =>
[2] => https
[3] =>
[4] =>
[5] =>
[6] =>
)
I want this result for constructing a URL. I have tried with preg_replace
and explode
function to get my expected result but I am failed.
回答1:
$text = '\u002522\u00253A\u002522https\u00253A\u00255C\u00252F\u00255C\\';
$text = preg_replace("#(\\\\[a-z0-9]{7})#is",",",$text);
$text_array = explode(",",trim($text,'\\'));
print_r($text_array);
来源:https://stackoverflow.com/questions/23426107/php-preg-replace-and-explode-function