Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted
$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);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.