It is necessary to divide the string into elements according to the regular expression. The input is a string like

http://(возмоТная приставка www)Π½Π°Π·Π²Π°Π½ΠΈΠ΅ сайта.Ρ€Ρƒ/Π΄Π°Ρ‚Π° Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Ym/|Π‘Π»ΠΎΠ²ΠΎ ΠΈΠ· Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… символов|Π΄Π°Ρ‚Π° Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Ymd|-|слово ΠΈΠ· Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… символов|-|случайноС число ΠΈΠ· Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… Ρ†ΠΈΡ„Ρ€|.|слово ΠΈΡ… Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… Π±ΡƒΠΊΠ²| 

Ie for example the link type

 http://www.site.ru/2013-07/lunniy2013-7-11-rost-don-860686.zip 

So that after conversion it was possible to work with an array of type

 $arr[0]=http://www.site.ru $arr[1]=Π΄Π°Ρ‚Π° Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Ym ΠΈ Ρ‚.Π΄ 

Please help me create a regular expression, while nothing sensible is working out.

    2 answers 2

     $str = "http://www.site.ru/2013-07/lunniy2013-7-11-rost-don-860686.zip"; echo $str; preg_match('#http://(.*)\/(\d+-\d+)\/(.*)(\d+-\d+-\d+)-(.*)-\d(\d+)\.(.*)$#isU',$str,$matches); echo "<pre>"; print_r($matches); echo "</pre>"; 
    • Thank you very much for the answer) - Danis92
     $url = "http://www.site.ru/2013-07/lunniy2013-7-11-rost-don-860686.zip"; preg_match_all("/(https?:\/\/(www\.)?.*?)\/(\d{4}-\d{2})\/(\w*)(\d{4}-\d-\d\d)-(.*)-(\d*)\.(\w*)/",$url,$result,PREG_SET_ORDER); array_shift($result[0]); unset($result[0][1]); $result = $result[0]; print_r($result); Array ( [0] => http://www.site.ru [2] => 2013-07 [3] => lunniy [4] => 2013-7-11 [5] => rost-don [6] => 860686 [7] => zip ) 
    • but I don’t understand regular expressions yet ((. Recently I have only studied them, although the principle is not completely understood. - IntegralAL
    • one
      Here you have a service for training :) gskinner.com/RegExr - Erdi
    • thanks, I will study) - IntegralAL